使用 winforms 、 mdi 、父子窗体,在父窗体下指定空间打开子窗体

发布于 2024-10-28 03:02:23 字数 314 浏览 3 评论 0原文

我有一个 winform MAINFORM ,需要以此形式打开子窗体,如图所示。黑色部分是面板&将包含一个否。具有多个节点的 LinkLabels 和 Treeview。在其余部分中,我想在单击面板上的链接标签时显示子表单。

子窗体应完全适合剩余空间,即不包括面板覆盖的空间的空间。

请帮我解决代码,如何将新表单放入左侧空间。

另外,我想问,我应该使用面板还是有其他一些控制可以更有效或更好。 另外,MAINFORM需要做成MdiContainer吗? 图表

I have a winform MAINFORM , and need to open child forms in this form as shown in the image. The black portion is a panel & would contain a no. of LinkLabels and Treeview with multiple nodes. In the rest of the portion i want to display the child forms when the linklabels on the panel would be clicked.

The child forms should exactly fit into the remaining space i.e. space excluding the space covered by the panel.

Please help me out with the code, how to fit the new form in the left space.

Also, i would like to ask, that, shall i use the panel or is there some other control which could be more efficient or better here.
Also, does the MAINFORM needs to be made an MdiContainer?
Diagram

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

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

发布评论

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

评论(2

踏雪无痕 2024-11-04 03:02:23

Winforms 已经自动执行此操作。您不必编写任何代码,只需在设计器中将面板控件的 Dock 属性设置为 Left 即可。深灰色MDI客户区自动缩小以占据剩余空间。您创建的任何 MDI 子窗口都不会与面板重叠,它们仅限于 MDI 客户区。

Winforms already does this automatically. You don't have to write any code, simply set the Dock property of the panel control to Left in the designer. The darkgray MDI client area automatically shrinks to occupy the remaining space. Any MDI child windows you create won't overlap the panel, they are constrained to the MDI client area.

淡墨 2024-11-04 03:02:23

我将在右侧停靠一个用户控制界面来填充剩余空间,每次单击链接时,我都会使用专为该链接标签内容设计的特定控件来填充控制界面。这样你就可以忘记任何与 MDI 相关的事情,至少对我来说,它会整洁很多。

更详细一点,更简单一点,基本上每次单击左侧的链接时,您都会创建一个用户控件,该控件显示该链接的相关内容并将其显示在右侧,停靠在主窗体上,以便它充满了屏幕。

然后,当单击另一个链接时,右侧的该控件将被删除并加载新的控件。阅读有关创建用户控件的内容并了解您对此方法的看法。

以下是帮助您入门的链接:在 C#.net 中创建和使用 Windows 窗体控件库(用户控件)

要将窗体拆分为多个部分,请查看 分割器控件

I'd have a user control interface on the right docked to fill the remaining space, and each time a link is clicked I'd populate the control interface with a specific control designed for that link labels content. That way you can forget about anything MDI related and for me at least, it would be a lot neater.

In a bit more detail, and a bit of a simpler way, basically everytime a link on the left is clicked, you create a user control that displays the relevant content for that link and display it on the right, docked to the main form so it fills the screen.

Then when another link is clicked, this control on the right is removed and the new one loaded. Have a read about creating user controls and see what you think about this method.

Here's a link to get you started: Creating and using Windows Forms Control Library (User Control) in C#.net

To split the form into sections, take a look at the Splitter control

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文