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

Jac*_*ost 7 .net c# mdi mdichild winforms

我正在研究一个库存软件,突然发现我需要一些主要形式,我应该通过它打开所有其他形式,所以我创建了一个名为frmMainPanel并使用菜单条将其链接到另一个我成功链接它们但是它们在主窗体之外打开,我使用以下代码链接它们

使用以下方法链接frmSaleInvoice表单:

frmSaleInvoice childForm = new frmSaleInvoice();
cs.show()
Run Code Online (Sandbox Code Playgroud)

现在我意识到我应该让他们成为主要形式的孩子,所以我尝试使用以下代码:

frmSaleInvoice childForm = new frmSaleInvoice();

childForm.MdiParent = this;
childForm.Show();
Run Code Online (Sandbox Code Playgroud)

但它说 **" Form that was specified to be the MdiParent for this form is not an MdiContainer."**

任何人都可以帮助我,我错了,我怎么能把一个名为frmSaleInvoice的表格制作成名为frmMainPanel的其他形式的孩子

Cro*_*ono 20

Mdi父级必须将其IsMdiContainer属性设置为True.您可以在frmMainPanel表单中的设计时设置此属性.


Dmi*_*try 8

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

  • 请将@ Crono的答案标记为已接受,这次他的速度提高了2秒.:) (4认同)
  • @Dmitry +1先生. (2认同)