MDI父窗体问题设置父窗体
我正在使用一个有子项的 MDI 父窗体,当它们被该父项调用时,它们显示得很好,并且我用来强化子窗体,
ChildForm child = new ChildForm();
child.IsMdiContainer= this;
child.Show();
一旦从父控件调用它们,它们就会很好地工作,但如果我从另一种形式不是任何父窗体的子窗体,那么它们不再是主要父窗体的子窗体,一个明显的原因是,当我在该独立窗体上强化它们时,我根本无法使用 child.MDIParent = this;因为它倾向于使独立的表单父级,但我也尝试过
MDIParentForm form = new MDIParentForm
ChildForm child = new ChildForm();
child.IsMdiContainer= form ;
child.Show();
,但这也没有帮助,而是抛出一个异常,即我尝试设置父级的表单不是 MDI 容器,然后对此我尝试并修改
MDIParentForm form = new MDIParentForm ;
form.IsMdiContainer= true;
ChildForm child = new ChildForm();
child.MDIParent = form ;
child.Show();
结果什么也没有出现
任何想法如何............
I am using a MDI parent form that has a childs and they show up very well when they are called up by this parent and i use to intensiate child form as
ChildForm child = new ChildForm();
child.IsMdiContainer= this;
child.Show();
works well as soon as they are called from parent control but if i call them from another form that is not child of any parent form then they no longer remains child of main parent one obvious reason is that when i intensiate them on that independent form is that I simply cannot use child.MDIParent = this; because it will tend to make independent form parent but i also have tried
MDIParentForm form = new MDIParentForm
ChildForm child = new ChildForm();
child.IsMdiContainer= form ;
child.Show();
but this also dose not help instead of this it throws an exception that the form that I am trying to set Parent is not MDI Container then to this I give a try and modify
MDIParentForm form = new MDIParentForm ;
form.IsMdiContainer= true;
ChildForm child = new ChildForm();
child.MDIParent = form ;
child.Show();
and in its result nothing appears
Any idea how to..........
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该将 Parent 设置为已经存在的 mdiform,而不是创建一个新的。
如果还没有 mdiform 的实例,您不仅应该创建该表单的实例,还应该显示它。
另请注意,我使用
mdiForm.IsMdiContainer
,据我所知,没有IsMdiParent
属性。You should set the Parent to be the already existing mdiform, not create a new one.
If there isn't an instance of the mdiform already, you should not only create an instance of the form, but also show it.
Also notice that I use
mdiForm.IsMdiContainer
, AFAIK there is noIsMdiParent
property.在父表单中编写此代码......
write this code in a parent form....
要从另一个子级创建子级,只需这样编写:
或者触发父级可以响应的自定义事件。
To create a child from another child, just write it like this:
Or fire a custom event that the parent can respond to.