就是为什么form1窗口还是会重复打开,而form4窗口却不会重复打开,这两个代码一样啊??????
private void 窗口1ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form childrenFrom1 in this.MdiChildren)
{
if (childrenFrom1.Name == "Form1")
{
childrenFrom1.Visible = true;
childrenFrom1.Activate();
return;
}
}
Form1 childrenForm1 = new Form1(); //这样子窗口创建出来,父窗口依然可以使用
childrenForm1.MdiParent = this;
childrenForm1.Show();
}
private void 窗口2ToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form childrenFrom4 in this.MdiChildren)
{
if (childrenFrom4.Name == "Form4")
{
childrenFrom4.Visible = true;
childrenFrom4.Activate();
return;
}
}
Form4 childrenForm4 = new Form4(); //这样子窗口创建出来,父窗口依然可以使用
childrenForm4.MdiParent = this;
childrenForm4.Show();
}
看看form1的name属性是什么。是不是没有设置,不等于Form1