如果VB.Net中的MDIParent表单上存在控件,如何使MDIChild表单出现? [英] How to make the MDIChild form appears if there is a control on the MDIParent form in VB.Net?

查看:109
本文介绍了如果VB.Net中的MDIParent表单上存在控件,如何使MDIChild表单出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,

我去过一个不合逻辑的编程案例:

我创建了MDIParent表单"Form1" ,然后将另一个表单"Form2" 添加到项目中,然后将"Form1"设置为"Form2" 通过以下代码在"Form1" 加载事件上:


Greetings,

I have been to an illogical programming case:

I have created MDIParent form "Form1" and then add another form "Form2" to the project then set "Form1" as the parent form of "Form2" on the "Form1" load event through the following code:


Dim ChildForm As New Form2
ChildForm.MdiParent = Me  'Which is Form1
ChildForm.Show()




现在,我向父窗体"Form1" 添加了面板"Panel1" ,并将其 Dock 属性设置为 Full 为了涵盖所有"Form1" .

奇怪的是,在"Form1" 的加载事件中,应该出现"Form2" ,但是发生的是它没有出现并且看起来像在"Panel1" 面板下.

那么,Vb.Net中使"Form2"(即"Form1" 的MDIChild)出现在添加到父窗体" Form1的所有控件之上的方法或语法是什么? "不在他们之下?

请指教...

提前谢谢....




Now I added a panel "Panel1" to the parent form "Form1" and set its Dock property to Full in order to cover all the "Form1".

What is weird is that at the load event of "Form1", "Form2" should appear, but what happened was that it didn`t appear and it looked like it is under the panel "Panel1".

So what is the method or syntax in Vb.Net that makes "Form2" which is the MDIChild of "Form1" to appear on top of all controls that are added to the parent form "Form1" and not under them?

Please advise...

Thanks in advance....

推荐答案

正在显示MdiChild表单.问题是您用固定在整个窗体上的面板覆盖了MdiParent窗体上的整个MdiClient控件.

删除面板控件.我不知道为什么你把它放在那里.

自动放置在MdiParent表单上的MdiClient控件已经停靠在表单中.您将必须搜索Form1的Controls集合以找到MdiClient控件,然后将其操纵到所需的任何条件(无论何种条件).您甚至可以调用它的BringToFront方法,但这将掩盖您放到Form1上的所有控件,包括您的面板,这有什么用呢?
The MdiChild form IS showing. The problem is you covered up the entire MdiClient control on the MdiParent form with a Panel Docked to the entire form.

Remove the Panel control. I have no idea why you put it there.

The MdiClient control that is automatically put on a MdiParent form is already Docked Full in the form. You would have to search the Controls collection of Form1 to find the MdiClient control, then manipulate it to whatever condition you need, whatever that is. You could even call it''s BringToFront method, but then that would cover up all the controls you dropped on Form1, including your panel, so what''s the point??


From Dave提出的问题和答案,我可以看到您正在滥用MDI.但这不是您的错,这是MDI设计人员的错:这是滥用UI合理感觉的MDI.这就是为什么即使Microsoft也不鼓励MDI的原因.微软努力摆脱它.例如,在WPF中不复制MDI.

忠告很简单:不要使用MDI,不要让您的生活变得更艰难,也不要以所有的丑陋来吸引客户.有更好更好的方法.

请参阅:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages [在WPF中使用MDI窗口的问题 [ ^ ],
MDIContainer提供错误 [如何在WPF中创建MDI父窗口? [ ^ ],
如何最大程度地设置子表单,最小化最后一个子表单 [ ^ ].

—SA
From your question and the answer by Dave I can see that you are abusing MDI. But this is not your fault, this is a fault of MDI designers: this is MDI that abuses the reasonable sense of the UI. That''s why MDI is highly discouraged, even by Microsoft. Microsoft tries hard to get rid of it. MDI is not reproduced in WPF, for example.

The advice is simple: don''t use MDI, don''t make your life harder and don''t chase off your customer with all that ugliness. There are much better and easier ways.

Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[^],
Question on using MDI windows in WPF[^],
MDIContainer giving error[^],
How to Create MDI Parent Window in WPF?[^],
How to set child forms maximized, last childform minimized[^].

—SA


问候,

谢谢你们的答复.

我只想澄清一下我在MDIParent表单中添加面板之后的观点...

我需要在MDIParent表单(即按钮,图片框)上具有一些控件,并且还需要在用户浏览应用程序时加载MDiChild表单(登录表单,客户端表单).因此,当用户单击按钮时,应在顶层(最顶部)而不是在这些按钮或图片框的后面打开子窗体.

所以我添加了面板并向其中添加了控件,因此我可以使其可见或不依赖于任何子窗体的加载.....

但是我认为这种设计还不是很成熟,因此我正在寻求更好的解决方案或解决方法,因为我真正需要的是加载子窗体,并且仍可看见中间窗体中的控件,但该控件位于子窗体和反之亦然...

如果我的英语不太懂,请执行一下...

请指教...
Greetings,

Thanks guys for your replies.

I just want to clarify my point behind the addition of a panel to the MDIParent form...

I need to have some controls on the MDIParent form (i.e. buttons, pictureboxes), and I also need to load a MDiChild forms (login form, client form) while the user is navigating through the application. So when a user clicks on a button, a child form should be opened on the top level (top most) and not behind those buttons or pictureboxes.

So I added the panel and add the controls to it and so I can make it visible or no depends on the loading of any childform.....

But I think that this design is not pretty mature, and so I`m seeking for a better solution or workaround since what I really need is to have the child form loaded and the controls in the mdiparent form still visible but behind the child form and not vice versa...

Please execuse me if my english is not very understandable...

Please advise...


这篇关于如果VB.Net中的MDIParent表单上存在控件,如何使MDIChild表单出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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