简体   繁体   English

vb.net子窗体落后于父窗体内部的面板控件

[英]vb.net child form falls behind panel control inside parent form

I am in a bit of a bother. 我有点烦。 I have a MDI.Parent form within it some blue pannels. 我有一个MDI.Parent表单,里面有一些蓝色面板。 When I call my child form, the child form falls behind the blue panels. 当我给孩子表格打电话时,孩子表格落在蓝色面板的后面。 I didn't expect this because the panels already existed at runtime whilst the child form is called latter (I though namely that new items alway ended up on top). 我没想到这一点,因为面板在运行时已经存在,而子窗体被称为后者(尽管我总是将新项放在最后)。

How do I fix this... Im using Vb.net for this 我该如何解决...我为此使用Vb.net

There's nothing to fix. 没什么要修复的。 That's the way it works. 这就是它的工作方式。

When you set the IsMdiContainer property of a form to True , what actually happens is an MdiClient control is added to your form to act as a host for the child forms. 当您将窗体的IsMdiContainer属性设置为True ,实际发生的是将MdiClient控件添加到窗体中以充当子窗体的宿主。 The grey background you see is actually that control, not the form. 您看到的灰色背景实际上是该控件,而不是表单。 When you add an MDI child form to the parent, is becomes a child control of that MdiClient . 当您将MDI子窗体添加到父窗体时,成为该MdiClient的子控件。

If you were to add a GroupBox to your form and put a Panel over it and then add a Button to the GroupBox , would you expect the Button to be visible over the Panel ? 如果要在窗体中添加GroupBox并在其上方放置一个Panel ,然后在GroupBox添加一个Button ,您是否希望该ButtonPanel上可见? I would hope not, because it won't. 我希望不会,因为不会。 This is no different. 没什么两样

The child form is basically part of the MdiClient control so anything that covers that covers the child form too. 子窗体基本上是MdiClient控件的一部分,因此覆盖该子窗体的所有内容也是如此。 If you're trying to do otherwise then you're abusing MDI. 如果您尝试执行其他操作,那么您将滥用MDI。 You can add Panels and dock them to the edges of the parent form but you're not supposed to have floating controls. 您可以添加Panels并将其停靠在父窗体的边缘,但是不应使用浮动控件。

With a bit of jiggery-pokery you can display an Image as a background or draw a gradient or the like but the MdiClient was not designed to host controls other than forms so you can't add controls to it either. 有了一点点麻烦,您就可以将Image作为背景显示或绘制渐变等,但是MdiClient并非旨在承载除表单之外的控件,因此也无法向其中添加控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM