反射通过命名空间.窗体名称,调用窗体
public void OpenChildForm(string formName) { Type t = Type.GetType(formName); Assembly asm = Assembly.GetExecutingAssembly(); DockContent frm = asm.CreateInstance(formName) as DockContent; if (frm != null) { frm.Show(this.dockPanelMain); } }
重复打开窗体监测
public bool CheckFormIsOpen(string formname) { bool remark = false; for (int a = 0; a < base.MdiChildren.Length; a++) { if (formname.Equals(base.MdiChildren[a].GetType().Namespace + "." + base.MdiChildren[a].GetType().Name)) { base.MdiChildren[a].Activate(); remark = true; } } return remark; }