呵呵,很简单,先定义一个窗体变量;
如:frmDirTool() DirTool = null;
然后再从生成这个窗体的点击事件中写入如下代码:呵呵,这个方法,就不用从关闭子窗体事件中写东西了
if(DirTool == null) //如果还没有字窗体时,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
else if(DirTool.IsDisposed) //如果曾有字窗体,但又关闭了,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
else if(DirTool.IsDisposed) //如果曾有字窗体,但又关闭了,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}