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

RadioButton选中时,触发什么控件,该如何解决

2012-06-18 
RadioButton选中时,触发什么控件在做一个winform窗体的项目,Form表单上有3个RadioButton,和一个Label,我想

RadioButton选中时,触发什么控件
在做一个winform窗体的项目,Form表单上有3个RadioButton,和一个Label,我想做成这样,当选中第一个radiobuttion时,Label.text=first,当选中第二个radiobutton时,Label.text=second。。。。

应该怎么做?

[解决办法]
双击第一个radiobuttion:
在事件里面写:
Label.text=first
双击第二个radiobuttion:
在事件里面写:
Label.text=second
[解决办法]

C# code
if(RadioButton1.Checked)   Label.Text = firstelse if(RadioButton2.Checked)   Label1.Text = secondelse if(RadioButton3.Checked)   Label1.Text = thirdelse    ...
[解决办法]
将3个RadioButton的CheckedChanged都绑定到下面的radioButton_CheckedChanged事件上。
C# code
        private void radioButton_CheckedChanged(object sender, EventArgs e)        {            RadioButton rb = sender as RadioButton;            if (rb.Text == "radioButton1")                this.label1.Text = "first";            else if (rb.Text == "radioButton2")                this.label1.Text = "secord";            else if (rb.Text == "radioButton3")                this.label1.Text = "three";        }
[解决办法]
同意LS和LSS的 我一般将3个RadioButton的click事件调用同一方法 方法里面同LSS
 if(RadioButton1.Checked)
Label.Text = first
else if(RadioButton2.Checked)
Label1.Text = second
else if(RadioButton3.Checked)
Label1.Text = third

[解决办法]
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
label1.Text = "first";
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
label1.Text = "second";
}
}
[解决办法]
C# code
        private void radioButton1_CheckedChanged(object sender, EventArgs e)        {            if (radioButton1.Checked)            {                label1.Text = "first";            }        }        private void radioButton2_CheckedChanged(object sender, EventArgs e)        {            if (radioButton2.Checked)            {                label1.Text = "second";            }        }
[解决办法]
探讨
C# code

if(RadioButton1.Checked)
Label.Text = first
else if(RadioButton2.Checked)
Label1.Text = second
else if(RadioButton3.Checked)
Label1.Text = third
else
...

[解决办法]
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
label1.Text = "first";
}
}

热点排行