MDI父窗体问题设置父 [英] MDI Parent Form Problem setting Parent

查看:149
本文介绍了MDI父窗体问题设置父的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用,有一个孩子的一个MDI父窗体和他们出现得非常好,当他们被这位家长叫过来,我用它来intensiate子形式

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();



只要它们是从父控件调用效果很好,但如果我从另一个窗体调用它们是没有任何父窗体子,然后便不再保持主父的孩子一个显而易见的原因是,当我intensiate他们独立的形式是,我根本没法用child.MDIParent =这一点;因为它往往会作出独立形式的父母,但我也有试过

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();



但是这也剂量不帮助,而不是这个它抛出一个异常,我想形式集父并不是MDI容器那么这个我给一个尝试和修改

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();

和在它的结果没有出现

任何想法如何..........

Any idea how to..........

推荐答案

要创建一个孩子一个孩子,只是把它写像这样的:

To create a child from another child, just write it like this:

ChildForm sibling = new ChildForm();
sibling.MdiParent = this.MdiParent;
sibling.Show();

或火灾的自定义事件,该家长可以应对。

Or fire a custom event that the parent can respond to.

这篇关于MDI父窗体问题设置父的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆