单选按钮 [英] Radio Button
本文介绍了单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在第二次单击时取消选中(单选按钮). (例如,我单击一次,它会打一个勾号-我再次单击它会删除它).
I want to uncheck a (radio button) on the 2nd click. (e.g. I click once, it puts a check mark - I click a second time, it removes it).
推荐答案
嗨
您可以使用相同的复选框.为什么要使用单选按钮.有任何特定要求吗,请在这里告诉我们.
Hi
you can use check box for same. why you want to use radio button for same. is there any specific requirement then please let us know here.
这将滥用众所周知的预期UI行为.正如Keyur Satyadev正确指出的那样,这是一个复选框行为(已可用).
(即使有人需要这样的东西,您的责任是拒绝它,解释为什么要这样做-沟通并调节情况.发生这种情况.)
This would be abuse of well-known and expected UI behavior. As Keyur Satyadev correctly put it, it''s a check box behavior (already available).
(Even is somebody required something like that, your responsibility is to deny it, explain why it should be done -- communicate and regulate the situation. Such things happen.)
我会建议您使用Checkbox控件,您可以在其中实际执行所要求的操作.
但是单选按钮只是您要使用的参考以下代码:
I will suggest you to use Checkbox control where you can actually do what you have asked.
But radio button is only that you want to use refer following code :
bool blnState;
public Form1()
{
InitializeComponent();
}
private void radioButton1_MouseDown(object sender, MouseEventArgs e)
{
blnState = radioButton1.Checked;
}
private void radioButton1_MouseUp(object sender, MouseEventArgs e)
{
radioButton1.Checked = !blnState;
}
其中radioButton1是您正在使用的单选按钮的名称.
我已经使用了此控件的mousedown和mouseup事件.
where radioButton1 is the name of the radio button that you are using.
I have used the mousedown and mouseup events of this control.
这篇关于单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文