繁体   English   中英

从另一个mdichild打开mdichild

[英]Open mdichild from another mdichild

我有以下形式:main_menu(mdicontainer),form1和form2。 我可以通过mdichild由main_menu中的from1打开

form1 newMDIChild = new form1();

newMDIChild.MdiParent = this;

newMDIChild.Show();

当我尝试通过form1将form2作为main_menu的mdichild打开时

form2 newMDIChild = new form2();

newMDIChild.MdiParent = this.MdiParent;

newMDIChild.Show;

this.close();

它仍以非子形式打开form2。 到目前为止,我没有找到任何解决方案。 有任何想法吗? 提前致谢。

在您的帖子中,您暗示两种形式都是同一父母的孩子。 如果是这种情况,则将form1的父级设置为正确的父级,但将form2的父级设置为其父级的父级。 实际上,它使form2成为生成它的对象的同级对象,而不是子对象。

尝试改变

newMDIChild.MdiParent = this.MdiParent;

newMDIChild.MdiParent = this;

生成表格2时

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM