日期:2014-05-19  浏览次数:20889 次

多窗口问题
三个窗口:Form1,Form2,Form3,
每个窗体上都有一个Button控件,单击Form1上面的BtnFrm2按钮就切换到Form2,不关闭Form1,再单击Form2上面的BtnForm3控钮关闭Form2同时打开Form3,不关闭Form1,单击Form3上面的BtnForm1按钮关闭Form3切换到Form1  
  请问这个如何实现,请简单写一下实现代码

------解决方案--------------------
Form1:
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 f = new Form2();
f.ShowDialog(this);
}
Form2:
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Form3 f = new Form3();
f.ShowDialog(this);
}
Form3:
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
((Form1) (((Form2)(this.Owner)).Owner)).Show();
}
------解决方案--------------------
Form1
private void button1_Click(object sender, EventArgs e)
{
Form2 f = new Form2();
this.Hide();
f.Show();
}
Form2
Form3 f = new Form3();
f.Show();


Form3
this.Hide();
Form1 f = new Form1();
f.Hide();
f.Show();
------解决方案--------------------
Form1

Form2 f = new Form2();
f.Show();

Form2
this.Hide();
Form3 f = new Form3();
f.Show();


Form3

this.Close();