指定为此表单的MdiParent的表单不是MdiContainer

问题描述 投票:7回答:4

我正在研究一个库存软件,突然发现我需要一些主要形式,我应该打开所有其他形式,所以我创建了一个名为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的其他形式的孩子

c# .net winforms mdi mdichild
4个回答
19
投票

Mdi父母必须将它的IsMdiContainer属性设置为True。您可以在frmMainPanel表单中设计此属性。


8
投票

您应该为父表单设置IsMdiContainer = true


0
投票

只需在代码中编写IsMdiContainer = true;即可。

Form2 fL = new Form2();
fL.MdiParent = this;
fL.Show();

Form2是您要显示的表单的名称。


-2
投票

你不必将childForm设置为true,你可以试试这个:

childForm.MdiParent = (name of your mdiparent form).ActiveForm;
childForm.Show();
© www.soinside.com 2019 - 2024. All rights reserved.