如何取消选中单选按钮 [英] how to uncheck the radio button
本文介绍了如何取消选中单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的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?
推荐答案
你应该使用CheckBox
。RadioButtons
是要选择的。
但是看看答案 - 我们如何取消选中单选按钮 [ ^ ]。
You should useCheckBox
instead.RadioButtons
are meant to be chose.
However look at the answer - How can we uncheck a radio button[^].
我建议您评估CheckBoxes是否满足您在此设计方案中的需求。
RadioButtons意味着在组中使用...例如,WinForms面板中的所有RadioButton都是组...其中一个将始终将其CheckState属性设置为'Checked。
通过使用Microsoft Windows用户界面指南设计用户界面,您将向用户展示他们熟悉的交互。以下是RadioButtons的指南:[ ^ ]。
在WinForms中,它可能是一种不一致的行为,一些RadioButton放在一些ContainerControl或Form上,最初出现在设计中 - 时间,然后在运行时,因为所有未经检查,除非你在设计时设置其中一个的checked属性。
I suggest you evaluate whether CheckBoxes meet your needs in this design scenario.
RadioButtons are meant to be used in groups ... for example, all the RadioButtons in a WinForms Panel are a "group" ... where one of them will always have its CheckState Property set to 'Checked.
By designing your user-interface using the Microsoft Windows User Interface Guidelines, you will presenting users with interactive they are familiar with. Here's guidelines for RadioButtons: [^].
In WinForms it is, perhaps, an inconsistent behavior that a bunch of RadioButtons put in some ContainerControl, or on a Form, initially appear at design-time, and then at run-time, as all unchecked unless you have at design-time set the checked property of one of them.
你好
hello
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;
}
}
这篇关于如何取消选中单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文