如何在MDI容器中显示子窗体而不在子窗体中显示容器窗体中的控件?

发布于 2024-10-01 05:53:44 字数 229 浏览 1 评论 0原文

在我的容器表单项目中,我使用按钮打开子表单,而不是条带菜单,但容器中的按钮始终出现在子表单上 如何将按钮或任何其他控件窗体置于子窗体之上 我正在使用 Visual Studio 2008 专业版 C# 编程语言 alt text

如此图中,按钮应该位于 form1 中,而不是可以在Form2(儿童)中看到 以及容器中的其他控件

in my project in the container form i use buttons to open the child forms , not Strip Menu but the buttons in the container always appears on the child form
how to privet the buttons or any other controls form being above the child form
i am using Visual Studio 2008 professional edition C# programming language alt text

as in this Image the button suppose to be in form1 and not to be seen in Form2 (Child)
and also the other controls in the Container

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

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

发布评论

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

评论(2

多情癖 2024-10-08 05:53:44

先生,我有

创建新的空表单的最佳解决方案,并且比

在 Form_load 事件中设置

private void bg_Load(object sender, EventArgs e)
        {
            this.ControlBox = false;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
        }

此表单的以下属性而不是之后
在 mdi 表单加载事件中编写以下代码,

  private void Main_Load(object sender, EventArgs e)
        {


            bg bg = new bg(); // create object of empty form my empty form name is "bg"
            bg.MdiParent = this;
            bg.Show();
        }

将您想要在后台添加到空表单中的内容添加到空表单中...]
享受

sir i have best solution for

create new empty form and than set following property of this form

set in Form_load event

private void bg_Load(object sender, EventArgs e)
        {
            this.ControlBox = false;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
        }

than after
write following code in mdi form load event

  private void Main_Load(object sender, EventArgs e)
        {


            bg bg = new bg(); // create object of empty form my empty form name is "bg"
            bg.MdiParent = this;
            bg.Show();
        }

what ever you want in background add into empty form....]
Enjoy

柏林苍穹下 2024-10-08 05:53:44

您应该使用 ToolStripMenuStrip 来调用您的子表单。就您而言,我假设您只需将一个按钮拖放到 Form1 中。这就是按钮浮动的原因。

但是,如果您坚持不懈并且仍然不想使用 ToolStrip 和 MenuStrip,您可以在显示子窗体后隐藏按钮。例如:

private void button1_Click(object sender, EventArgs e)
{
     Form2 f2 = new Form2();
     f2.MdiParent = form1;
     f2.Show();
     button1.Visible = false; // This will cause your button to be hidden.
}

You should use ToolStrip or MenuStrip to call your child form. In your case, I assume you just drag and drop a Button into your Form1. That's why the button is floating.

But if you are persistent and still don't want to use ToolStrip and MenuStrip, you can hide the button after showing the childform.. Ex:

private void button1_Click(object sender, EventArgs e)
{
     Form2 f2 = new Form2();
     f2.MdiParent = form1;
     f2.Show();
     button1.Visible = false; // This will cause your button to be hidden.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文