首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于 radiobutton的有关问题

2011-12-29 
关于 radiobutton的问题现有六个radiobutton如何取已经选择的那个radiobutton的text值?谢谢 [解决办法]for

关于 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;
}
[解决办法]
都对!

热点排行