private bool HaveOpened(Form 父窗体, string 子窗体Name)
{
//查看窗口是否已经被打开
bool bReturn = true;
for (int i = 0; i < 父窗体.MdiChildren.Length; i++)
{
if (父窗体.MdiChildren[i].Name == 子窗体Name)
{
父窗体.MdiChildren[i].BringToFront();
bReturn = false;
break;
}
}
return bReturn;
}
打开窗体时调用上述方法:
Form1 f1=new Form();
if (HaveOpened(父窗体, "子窗体Name"))
{
f1.MdiParent = 父窗体;
f1.Show();
}
阅读(5855) | 评论(0) | 转发(0) |