public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void ToolCollectorClick(object sender, EventArgs e) { AddForm(new frmWebCollector()); } private void AddForm(Form frm) { if(MdiChildren.Any(p=>p.GetType().Name==frm.GetType().Name)) { frm.Activate(); } else { frm.MdiParent = this; frm.Show(); } } }
在父窗体上调用AddForm创建新子窗体。