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

发布于 2024-11-29 05:46:24 字数 616 浏览 4 评论 0原文

当子窗体打开时,它隐藏在 MDI 父容器的标题栏后面。

在此处输入图像描述

子窗体的 WindowState 设置为 MaximizedFormBorderStyle 设置为 None

如果我最小化 MDI 父窗体并最大化它,则子窗体会出现在前面。

如何克服这种情况呢?

编辑:

我使用以下代码打开子表单。

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

When a child form is opened it is hidden behind the title bar of MDI Parent Container.

enter image description here

The Child form's WindowState is set to Maximized. FormBorderStyle is set to None.

If I minimize the MDI parent and maximize it, then the child form comes in to front.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

寂寞花火° 2024-12-06 05:46:24

尝试以下代码。

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

Try the following code.

    Form1 newMDIChild = new Form1();
    newMDIChild.MdiParent = this;
    newMDIChild.Show();
    this.LayoutMdi(MdiLayout.Cascade);
    newMDIChild.Dock = DockStyle.Fill;
邮友 2024-12-06 05:46:24

本机 Windows MDI 实现无法处理无边框 MDI 子窗口。不幸的是,Winforms 忘记强制执行该限制。您可以在 Show() 调用之后移动 WindowState 赋值,但这会导致另一个问题。

只是不要使其无边框,无论如何边框都是不可见的。

The native Windows MDI implementation cannot deal with borderless MDI child windows. Unfortunately, Winforms forgets to enforce that restriction. You can move the WindowState assignment after the Show() call but that causes another problem.

Just don't make it borderless, the border isn't visible anyway.

吃不饱 2024-12-06 05:46:24
AboutBox1 ab = new AboutBox1();
ab.MdiParent = MDIForm.ActiveForm;
ab.TopMost = true;
ab.Show();
AboutBox1 ab = new AboutBox1();
ab.MdiParent = MDIForm.ActiveForm;
ab.TopMost = true;
ab.Show();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文