- 前提:需要三个窗体,每个窗体里至少有两个radioButton控件 //注释:其实两个窗体就够了
- 接着需要把 Form2,Form3 中radioButton的Modifiers属性值改为 Public
- 最后就是代码部分
代码部分
Form1 : Form
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked==true)//判断radioButton1有没有被选中 { Form2 f2 = new Form2();//实例化窗体 f2.Owner = this;//获取f2的窗体控件 f2.radioButton1.Checked = true;//f2的radioButton1被选中的状态为真 f2.Show();//显示f2窗体 } if (radioButton2.Checked == true)//判断radioButton1有没有被选中 { Form2 f2 = new Form2();//实例化窗体 f2.Owner = this;//获取f2的窗体控件 f2.radioButton2.Checked = true;//f2的radioButton2被选中的状态为真 f2.Show();//显示f2窗体 } }
|
Form2 : Form
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked==true) { Form3 f3 = new Form3(); f3.Owner = this; f3.radioButton1.Checked = true; f3.Show(); } if (radioButton2.Checked == true) { Form3 f3 = new Form3(); f3.Owner = this; f3.radioButton2.Checked = true; f3.Show(); } }
|
Form3 : Form