如果你总是要if(raidiobutton1.checked) 来判断 太累了
方法一:
使用:
foreach(Control c in Controls)
if(c is checkBox )
if((控件属性)c属性条件判断)
初加载时,预选的radioButton (但一定要小心
Trim()
如果有空格要除去)
foreach(Control c in Controls)
{
if (c is RadioButton)
{
if ((((RadioButton)c).Text).Equals(tspec))
((RadioButton)c).Checked = true;
else ((RadioButton)c).Checked = false;
}
}
得到选中的RadioButton的文本内容
string tspec="";
foreach(Control c in Controls)
{
if(c is RadioButton)
{
if (((RadioButton)c).Checked)
tspec = ((RadioButton)c).Text;
}
}
方法二
使用控件数组
RadioButton[] rb = new Radi