MDI 窗体内的可拖动 ToolStrip 控件

发布于 2025-01-02 23:21:48 字数 388 浏览 3 评论 0原文

我有一个 .NET MDI(多文档界面)应用程序,我想使用可拖动的 ToolStrip 控件。我希望 ToolStrip 控件位于 MDI 窗体的顶部(就在菜单下方)。当我在 MDI 表单中使用标准 ToolStripContainer 时,我无法仅显示顶部对接条,它始终显示中心内容面板,并在我的 MDI 应用程序中隐藏子表单。我尝试将 ToolStripContainer 停靠设置为“顶部”(而不是“填充”),但内容面板仍然显示,并且当我有多行 ToolStrip 控件时,它无法正确调整大小。

有没有办法隐藏 ToolStripContainer 的内容面板,以便它在 MDI 表单中正常运行?如果没有,如何在 MDI 表单中获取可拖动的 ToolStrip 控件? MDI 应用程序中可拖动的 ToolStrip 似乎是一个常见的请求。

I've got a .NET MDI (multiple document interface) application that I want to use draggable ToolStrip controls. I want the ToolStrip controls to be at the top of my MDI form (just under the menus). When I use the standard ToolStripContainer inside the MDI form I can't show just the top docking strip, it always shows the center content panel and that hides and child forms in my MDI application. I tried setting the ToolStripContainer docking to "top" (instead of "fill") but the content panel is still shown and it doesn't resize correctly when I have multiple lines of ToolStrip controls.

Is there a way to hide the content panel of the ToolStripContainer so it plays nice in an MDI form? If not, how do I get draggable ToolStrip controls in an MDI form? It would seem like draggable ToolStrips in MDI applications would be a common request.

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

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

发布评论

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

评论(1

会傲 2025-01-09 23:21:48

我找到了解决方案!默认情况下,工具箱中未列出一个控件,该控件完全符合我的要求。它是 System.Windows.Forms.ToolStripPanel 控件。

  1. 在“工具箱”窗口中,右键单击并选择“选择项目...”
  2. 将出现“选择工具箱项目”窗口。向下滚动到 ToolStripPanel 控件并选中该框。单击“确定”
  3. 现在将 ToolStripPanel 拖到 MDI 窗体上并将停靠设置为“顶部”。
  4. 现在,您可以将 ToolStrip 控件放入面板中,它们将是可拖动的,面板将正确调整大小(到多行),并且您的 MDI 子项仍然可见!

I found the solution! There is a control that is not listed in the Toolbox by default that does exactly what I want. It is the System.Windows.Forms.ToolStripPanel control.

  1. In the Toolbox window, right click and select "Choose Items..."
  2. A "Choose Toolbox Items" window will appear. Scroll down to the ToolStripPanel control and check the box. Click "OK"
  3. Now drag a ToolStripPanel onto your MDI form and set the Docking to "top".
  4. You can now put ToolStrip controls inside the panel and they will be draggable, the panel will resize (to multiple rows) correctly, and your MDI children are still visible!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文