在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
private bool HaveOpened(Form 父窗体, string 子窗体Name) 打开窗体时调用上述方法:
Form1 f1=new Form();
通过窗口名判断是否已经打开窗口,如此做的好处就是一个窗体通过不同的Name打开多个这个窗口 比如说不同的模块打开不同的Mdi父窗体.但相同的Name只能打开一个 /// <summary> /// 判断是否打开Mdi的窗口,如打开则得到窗口 /// </summary> /// <param name="asFormName"></param> /// <returns></returns> public Form CheckMdiFormIsOpen(string asFormName) { Form form = null; foreach (Form frm in Application.OpenForms) { if (frm.Name == asFormName) { form = frm; break; } } return form; } private bool ContainMDIChild(string childTypeString) { Form form = null; foreach (Form form2 in base.MdiChildren) { if (form2.GetType().ToString() == childTypeString) { form = form2; break; } } if (form != null) { //form.TopMost = true; form.Show(); form.Focus(); return true; } return false; } private bool ContainChild(string childTypeString) { Form form = null; foreach (Form form2 in Application.OpenForms) { if (form2.GetType().ToString() == childTypeString) { form = form2; break; } } if (form != null) { //form.TopMost = true; form.Show(); form.Focus(); return true; } return false; }
|
请发表评论