/// <summary> /// 打开子菜单 /// 可以判断是否被打开,已经被打开则激活 /// </summary> /// <param name="childType">typeof(From)获取子菜单类型</param> private void OpenChildForm(Type childType)//传进子窗口的类型,如何获得类型呢? { bool isOpened = false; foreach (Form child in this.MdiChildren) { if (child.GetType() == childType) { child.Activate(); isOpened = true; break; } } if (!isOpened) { //动态创建form实例 Form frm = (Form)Activator.CreateInstance(childType); frm.MdiParent = this; frm.WindowState = FormWindowState.Maximized; frm.Show(); } }