日期:2014-05-20  浏览次数:20656 次

关于 radiobutton的问题
现有六个radiobutton    
如何取已经选择的那个radiobutton的text值?
谢谢


------解决方案--------------------
foreach (Control vControl in Controls)
if ((vControl is RadioButton) &&
(((RadioButton)vControl).Checked))
{
Text = ((RadioButton)vControl).Text;
break;
}

------解决方案--------------------
遍历
string str;
foreach( control ctl in group.controls )
{
if( typeof(ctl) == RaidonButton )
{
if(ctl.checked)
{
str = ctl.Text;
return;
}
}
}
------解决方案--------------------
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
string strButtonText= " ";
if (radioButton1.Checked)
strButtonText = radioButton1.Text;
if (radioButton2.Checked)
strButtonText = radioButton2.Text;
if (radioButton3.Checked)
strButtonText = radioButton3.Text;
if (radioButton4.Checked)
strButtonText = radioButton4.Text;
if (radioButton5.Checked)
strButtonText = radioButton5.Text;
if (radioButton6.Checked)
strButtonText = radioButton6.Text;
}
------解决方案--------------------
都对!