本文介绍了如何取消选中单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的c#应用程序中,我需要radiobutton,但是如果用户单击一个单选按钮,他们就无法取消它们(所以一旦他们选择了它,它就成为强制性的)。我无法取消它们。有人会提出这个想法吗?
In my c# application, I need radiobutton, but if the user clicks a radio button they can't unclick them (so it becomes mandatory once they've chosen one). I can not unclick them. can some one give the idea?
推荐答案
bool isChecked =false;
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
isChecked = radioButton1.Checked;
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked && !isChecked)
radioButton1.Checked = false;
else
{
radioButton1.Checked = true;
isChecked = false;
}
}
这篇关于如何取消选中单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!