在一个Form窗口中定义了3个radiobutton,radioButton1、radioButton2和radioButton3,以及button1和button2(这里可以是其他控件)
为了实现单击radioButton1时,button1显示"A1",button2显示"A2";
单击radioButton2时,button1显示"B1",button2显示"B2";
单击radioButton3时,button1显示"C1",button2显示"C2".
下面代码就可以实现这个功能:
private void radioButton1_CheckedChanged(object sender, EventArgs e) { if(radioButton1.Checked == true) { button1.Text == "A1"; button2.Text == "A2"; } if(radioButton2.Checked == true) { button1.Text == "B1"; button2.Text == "B2"; } if(radioButton3.Checked == true) { button1.Text == "C1"; button2.Text == "C2"; } }
请发表评论