public static object loadForm(Form formToLoad, TabControl homeTabControl)
{
//Check if formToLoad parameter is NULL
if (formToLoad == null) throw new ArgumentNullException("formToLoad");
//get the parent/ownining form
Form form1 = new Form1();
//set formToLoad properties
formToLoad = new Form
{
Owner = form1,
FormBorderStyle = FormBorderStyle.None,
TopLevel = false,
Dock = DockStyle.Fill
};
//add formToLoad to tabControl tabPage
homeTabControl.TabPages["tabPageHome"].Controls.Add(formToLoad);
formToLoad.Show();
return formToLoad;
}
当我通过单击按钮调用我的代码时,为什么 formToLoad 不显示在 tabControl 页面中?
private void button3_Click(object sender, EventArgs e)
{
LeaveMainForm lM = new LeaveMainForm();
AppCode.FormLoader.loadForm(lM, homeTabControl);
}