控制只生成一个子窗体(简单)
呵呵,很简单,先定义一个窗体变量;
如:frmDirTool() DirTool = null;
然后再从生成这个窗体的点击事件中写入
if(DirTool ==null)
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
---------------------------------------如:frmDirTool() DirTool = null;
然后再从生成这个窗体的点击事件中写入
if(DirTool ==null)
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
还要控制第二次打开新的子窗体
if(DirTool == null) //如果还没有字窗体时,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
else if(DirTool.IsDisposed) //如果曾有字窗体,但又关闭了,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
if(DirTool == null) //如果还没有字窗体时,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}
else if(DirTool.IsDisposed) //如果曾有字窗体,但又关闭了,则创建新的子窗体
{
DirTool = new frmDirTool();
DirTool.MdiParent = this;
DirTool.Show();
}