|
发表于 2015-7-30 08:30:58
|
显示全部楼层
Form2 f2 = null;
Form3 f3 = null;
private void 窗体2ToolStripMenuItem_Click(object sender, EventArgs e)
{
//子窗口已经被销毁,但对象却不为null (c#的垃圾回收有问题,已被销毁,却不是NULL)
if (f2 == null || f2.IsDisposed)
{
f2 = new Form2();
}
f2.MdiParent = this; //建立父子关系
f2.Show(); //显示子窗口
f2.Focus(); //子窗口获得焦点
}
private void 窗体3ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (f3 == null || f3.IsDisposed)
{
f3 = new Form3();
}
f3.MdiParent = this; //建立父子关系
f3.Show(); //显示子窗口
f3.Focus(); //子窗口获得焦点
} |
|