110,534
社区成员
发帖
与我相关
我的任务
分享
if (this.MdiChildren.OfType<Form2>().Count() > 0)
{
this.MdiChildren.OfType<Form2>().First().Activate();
}
else
{
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
}
简单点的就是这样
private bool ShowChild(Form frm)
{
foreach (Form frm1 in this.MdiChildren)
{
if (frm1.Text==frm.Text)
{
frm1.WindowState = FormWindowState.Maximized;
frm1.Show();
return true;
}
}
return false;
}
foreach (Form childrenForm in Application.OpenForms) //判断窗体是否已经打开,如果打开则激活
{
if (childrenForm.Name == "你窗体的名称")
{
childrenForm.Visible = true;
childrenForm.Activate();
return;
}
}
你窗体 frm = new yhll_你窗体("", "", "F001", "0", "0");
frm.Show(); //没有打开,则实例化显示