我有以下表单: main_menu(mdicontainer),form1和form2。我可以在main_menu中以mdichild的身份打开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作为非子窗体打开。到目前为止,我还没有找到任何解决方案。有什么想法吗?提前谢谢。
发布于 2013-03-28 23:16:49
在您的帖子中,您暗示这两个表单都是同一父级的子级。如果是这种情况,则Form1的父级被设置为正确的父级,而Form2的父级被设置为其父的父级。实际上,它使form2成为派生它的对象的兄弟,而不是子对象。
试着改变
newMDIChild.MdiParent = this.MdiParent;至
newMDIChild.MdiParent = this;在生成Form2时。
https://stackoverflow.com/questions/15685409
复制相似问题