To display a child form inside a top-level form?该怎么解决
To display a child form inside a top-level form?该怎么解决
日期:2014-05-18 浏览次数:20869 次
To display a child form inside a top-level form? 我有两个form:frmMain,frmAddProduct,我在frmMain中想显示frmAddProduct,frmAddProduct上有添加产品的控件了,怎么解决啊? private void frmMain_Load(object sender, EventArgs e) { //this.Hide(); //frmAddProduct frm = new frmAddProduct(); //frm.ShowDialog(); Common common = new Common(); common.ShowChildForm(frmAddProduct.CreateObject(), this, true); } common.cs: public void ShowChildForm(System.Windows.Forms.Form childForm, System.Windows.Forms.Form parentForm, bool isModalWin) { if (childForm != null) { childForm.MdiParent = parentForm; if (isModalWin) childForm.ShowDialog(); //error //Form that is not a top-level form cannot be displayed as a modal dialog box. Remove the form from any parent form before calling showDialog. else childForm.Show(); } }