winform实现父窗体里面只能打开一个子窗体
使用Application.OpenForms解决 if(Application.OpenForms["Form1"]==null) { Form1 frm =new Form1(); frm.Show(); frm.MdiParent=this; } else{ Application.OpenForms["Form1"].Show(); } //在mdi窗体中显示一个子窗体 //调用方法 Form form1 = new Form(); open(form1); private void open(Form form) { if (!form.Created) { foreach (var item in this.MdiChildren) { item.Close(); } form = (Form)Activator.CreateInstance(form.GetType()); form.MdiParent = this; form.Show(); } else { form.Focus(); } } //将form 窗体中显示中mdi窗体中 Form2 form = new Form2(); form.MdiParent = this; form.Show();