panel2.Controls.Clear(); frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; frm.ShowIcon = false; frm.ShowInTaskbar = false; frm.BackColor = Color.White; //要将是否顶级控件设置为false,否则会报错 frm.TopLevel = false; frm.Dock = DockStyle.Fill; panel2.Controls.Add(frm); ////TabPage tab = new TabPage(frm.Name); ////tab.Controls.Add(frm); ////tabControl1.TabPages.Add(tab); ////tab.Show(); frm.Show(); frm.BringToFront(); frm.Focus();