打开一个的同时,关闭现在打开的所有子窗体
if(this.MdiChildren.Length>0)
{
foreach(Form child in this.MdiChildren)
{
child.Close();
}
}
Form abc=new Form();
abc.show();
private void Form1_Load(object sender, System.EventArgs e)
{
Form2 f=new Form2();
f.MdiParent=this;
f.Show();
Form3 ff=new Form3();
ff.MdiParent=this;
ff.Show();
}
private void button1_Click(object sender, System.EventArgs e)
{
if(this.MdiChildren.Length>0)
{
foreach(Form child in this.MdiChildren)
{
child.Close();
}
}
Form4 f=new Form4();
f.MdiParent=this;
f.Show();
}