简体   繁体   English

子窗体隐藏在 MDI 父容器后面

[英]Child Form is hidden behind MDI Parent Container

When a child form is opened it is hidden behind the title bar of MDI Parent Container.打开子窗体时,它隐藏在 MDI 父容器的标题栏后面。

在此处输入图像描述

The Child form's WindowState is set to Maximized . Child 窗体的WindowState设置为Maximized FormBorderStyle is set to None . FormBorderStyle设置为None

If I minimize the MDI parent and maximize it, then the child form comes in to front.如果我最小化 MDI 父级并最大化它,那么子窗体就会出现在前面。

How to overcome this situation?如何克服这种情况?

Edit:编辑:

I use the following code to open a child form.我使用以下代码打开子窗体。

    this.childForm= new ChildForm();
    this.childForm.MdiParent = this;
    this.WindowState = FormWindowState.Maximized;

    this.childForm.Dock = DockStyle.Fill;
    this.childForm.Show();
    this.childForm.BringToFront();
    this.childForm.Focus();

Try the following code.试试下面的代码。

    Form1 newMDIChild = new Form1();
    newMDIChild.MdiParent = this;
    newMDIChild.Show();
    this.LayoutMdi(MdiLayout.Cascade);
    newMDIChild.Dock = DockStyle.Fill;

The native Windows MDI implementation cannot deal with borderless MDI child windows.本机 Windows MDI 实现无法处理无边界 MDI 子 windows。 Unfortunately, Winforms forgets to enforce that restriction.不幸的是,Winforms 忘记强制执行该限制。 You can move the WindowState assignment after the Show() call but that causes another problem.您可以在 Show() 调用之后移动 WindowState 分配,但这会导致另一个问题。

Just don't make it borderless, the border isn't visible anyway.只是不要让它无边界,反正边界是不可见的。

AboutBox1 ab = new AboutBox1();
ab.MdiParent = MDIForm.ActiveForm;
ab.TopMost = true;
ab.Show();

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

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