我正在研究一个库存软件,突然发现我需要一些主要形式,我应该打开所有其他形式,所以我创建了一个名为frmMainPanel并使用菜单条将其链接到另一个我成功链接它们但是它们在主窗体之外打开,我使用以下代码链接它们
使用以下方法链接frmSaleInvoice表单:
frmSaleInvoice childForm = new frmSaleInvoice();
cs.show()
现在我意识到我应该让他们成为主要形式的孩子,所以我尝试使用以下代码:
frmSaleInvoice childForm = new frmSaleInvoice();
childForm.MdiParent = this;
childForm.Show();
但它说**" Form that was specified to be the MdiParent for this form is not an MdiContainer."**
任何人都可以帮助我,我错了,我怎么能把一个名为frmSaleInvoice的表格制作成名为frmMainPanel的其他形式的孩子
Mdi父母必须将它的IsMdiContainer
属性设置为True
。您可以在frmMainPanel
表单中设计此属性。
您应该为父表单设置IsMdiContainer = true
。
只需在代码中编写IsMdiContainer = true;
即可。
Form2 fL = new Form2();
fL.MdiParent = this;
fL.Show();
Form2
是您要显示的表单的名称。
你不必将childForm
设置为true,你可以试试这个:
childForm.MdiParent = (name of your mdiparent form).ActiveForm;
childForm.Show();