要完成你的需求,目前只有这样写,已经测试过,没问题。还有这里应该用ELSE IF,不该用IF。应该是radioButton1.Text;而不是直接赋值。
private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 4; i++)
{
if (radioButton1.Checked == true)
{
this.label1.Text = radioButton1.Text;
}
else if (radioButton2.Checked == true)
{
this.label1.Text = radioButton2.Text;
}
else if (radioButton3.Checked == true)
{
this.label1.Text = radioButton3.Text;
}
else if (radioButton4.Checked == true)
{
this.label1.Text = radioButton4.Text;
}
}
}
触发radioButton点击事件的时候,如果radioButton1被选中 label1.Text = "asd"
.......radioButton2被选中 label1.Text ="xzcxcz"
....... radioButton3被选中label1.Text = "vvbnbn";
if(this.控件ID.SelectedValue=="1")
{
lable.text="你要的值"
}
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this.label1.Text = "radioButton1";
}
if (radioButton2.Checked)
{
this.label1.Text = "radioButton2";
}
if (radioButton3.Checked)
{
this.label1.Text = "radioButton3";
}
if (radioButton4.Checked)
{
this.label1.Text = "radioButton4";
}
}