日期:2014-05-18 浏览次数:20849 次
if(RadioButton1.Checked) Label.Text = first else if(RadioButton2.Checked) Label1.Text = second else if(RadioButton3.Checked) Label1.Text = third else ...
------解决方案--------------------
将3个RadioButton的CheckedChanged都绑定到下面的radioButton_CheckedChanged事件上。
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";
}
}
------解决方案--------------------
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"; } }
------解决方案--------------------