我如何获得这单选按钮从组框检查? [英] How do I get which radio button is checked from a groupbox?
本文介绍了我如何获得这单选按钮从组框检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些groupboxes:
I have these groupboxes:
我要根据就像一个单选按钮的检查真实状态运行一些代码:
I want to run some code according to checked true state of a radio button like:
string chk = radiobutton.nme; // Name of radio button whose checked is true
switch(chk)
{
case "Option1":
// Some code
break;
case "Option2":
// Some code
break;
case "Option3":
// Some code
break;
}
是否有任何直接的方式,使我只能得到检查的名称单选按钮?
Is there any direct way so that I can only get the name of the checked radio button?
推荐答案
您可以找到所有选中的单选按钮像
You can find all checked RadioButtons like
var buttons = this.Controls.OfType<RadioButton>()
.FirstOrDefault(n => n.Checked);
此外看一看的 的CheckedChanged
事件。
时发生经过属性的值更改。
Occurs when the value of the Checked property changes.
这篇关于我如何获得这单选按钮从组框检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文