设置个窗体只能弹出一次 设置个窗体只能弹出一次 #region 设置个窗体只能弹出一次/**//**//**//// <summary>/// 控制只弹出一个子窗体/// </summary>/// <param name="type">子窗体类型</param>public void FilmShow(Type type){ Form[] f = this.MdiChildren; foreach (Form form in f) { if (form.GetType().Name == type.Name) { form.Activate(); return; } } Assembly a = Assembly.GetExecutingAssembly(); Form ff = (Form)a.CreateInstance(type.FullName); ff.MdiParent = this; ff.Show(); //this.statusBarPanel3.Text = this.ActiveMdiChild.Text.ToString();}/**//**//**//// <summary>/// 该窗体以模式窗体形式弹出/// </summary>/// <param name="type"></param>public void FilmShowDialog(Type type){ Form[] f = this.MdiChildren; foreach (Form form in f) { if (form.GetType().Name == type.Name) { form.Activate(); return; } } Assembly a = Assembly.GetExecutingAssembly(); Form ff = (Form)a.CreateInstance(type.FullName); ff.ShowDialog(); //this.statusBarPanel3.Text = this.ActiveMdiChild.Text.ToString();}#endregion 下面是如果调用该方法 private void menuItem2_Click( object sender, System.EventArgs e) { //密码修改,弹出模式窗体 this.FilmShowDialog(typeof(AdminPwdUpdate));} private void menuItem4_Click( object sender, System.EventArgs e) { //类别管理,弹出子窗体 this.FilmShow(typeof(TypeForm));} 转载于:https://www.cnblogs.com/di305449473/archive/2008/07/18/1245779.html