如何从MDIparent表单中的另一个MDIchild表单打开MDIchid表单 [英] How to open a MDIchid form from another MDIchild form within a MDIparent form

查看:91
本文介绍了如何从MDIparent表单中的另一个MDIchild表单打开MDIchid表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
在这里,我有4种形式(Form1,Form2,Form3和Form4),Form1是MdiContainer(IsMdiContainer = true;),Form2,Form3和Form4是Mdichild形式.
在Form1 Load事件中,我编写了如下代码:

Hello,
Here i is have 4 forms(Form1, Form2, Form3 and Form4) Form1 is MdiContainer(IsMdiContainer = true;), Form2, Form3 and Form4 are Mdichild forms.
In Form1 Load event i wrote the code as follows:

private void Form1_Load(object sender, EventArgs e)
     {
         Form2 f2 = new Form2();
         f2.MdiParent = this;
         f2.ShowDialog(); 
     }


在Form2表单中,我有两个按钮,分别称为"btnf3"和"btnf4".
1.如果我单击"btnf3"
我拥有将Form3作为Form1的MDI子窗体打开的功能,并且此Form2也必须关闭. (为结束此操作,我写了this.Hide();)
2.如果我单击"btnf4",我想以Form1的MDI子窗体形式打开Form4,并且还必须关闭Form2(MDI子窗体).

请告诉我我应该在那些按钮单击事件中写些什么
在此先谢谢您.


In Form2 form i have two buttons called "btnf3"and "btnf4".
1.If i click on "btnf3"
i wnat to open Form3 as a MDI child form of Form1 and also this Form2 has to be closed. (for closing this i wrote this.Hide();)
2.If i click on "btnf4" i want to open Form4 as a MDI Child form of Form1 and also close Form2 (MDI child form) has to be closed.

Please tell me what should i write in those buttons click events
Thanks... in advance.

推荐答案

这是正确执行操作的最佳方法:从不使用MDI.

这是一个主意:谁曾经需要MDI?为什么要折磨自己并吓users用户?
帮自己一个忙:完全不要使用MDI.没有设计,您可以更轻松地实现设计,并且质量更高.即使Microsoft也不鼓励使用MDI,实际上,Microsoft已将其从WPF中删除,并且几乎不支持它.更重要的是,如果您使用MDI,则会吓跑所有用户.只是不要.我可以解释该怎么办.

请参阅:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [如何在WPF中创建MDI父窗口? [ ^ ].

并且还请查看我过去的答案以解释该怎么做:
在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何设置最大化的子表单,最后一个子表单最小化 [ ^ ].

祝你好运,
—SA
Here is the best way of doing things right: never using MDI.

Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don''t. I can explain what to do instead.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
How to Create MDI Parent Window in WPF?[^].

And please also see my past answers explaining what to do:
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to set child forms maximized, last child form minimized[^].

Good luck,
—SA


看看类似的讨论:
Take a look at similar discussion: How to Open Child Window in tab[^]


这篇关于如何从MDIparent表单中的另一个MDIchild表单打开MDIchid表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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