仅调整 panel1 大小的 SplitContainer

发布于 2024-09-14 14:42:28 字数 481 浏览 3 评论 0原文

有没有办法让SplitContainer只调整panel1的大小?我有一个垂直 SplitContainer,当我移动拆分器时,我希望第一个面板的大小增加/减少,但我不想更改第二个面板的大小,我希望表单的大小增加和减少。

我创建了一些代码来增加/减小表单的大小,但 Panel2 也在更改大小,因此整个面板并不总是可见。

我是否必须制作自己的容器,或者可以使用 SplitContainer 实现这一点吗?

我有一个表单“MainWin”,其中包含面板“MainPanel”,MainPanel 包含 SplitContainer“MainSplitContainer”。 Panel1 包含一个 TreeView,Panel2 包含 3 个面板,这些面板根据在 TreeView 中选择的项目而变得可见。我希望这 3 个面板始终完全可见(我计划限制拆分器的扩展,以便表单无法扩展到屏幕之外),这是可能的还是我应该创建自己的控件并使用MouseDown、MouseUp 和 MouseMove 事件?

Is there a way to make the SplitContainer only adjust the size of panel1? I have a Vertical SplitContainer and when I move the splitter I would like the size of the first panel to increase/decrease, but rather than change the size of the second panel I want the form to increase and decrease in size.

I created some code to increase/decrease the size of the form, but Panel2 is also changing size so the entire panel is not always visible.

Am I going to have to make my own container, or is this possible with the SplitContainer?

I have a form "MainWin" that contains a Panel "MainPanel" MainPanel contains the SplitContainer "MainSplitContainer". Panel1 contains a TreeView, and Panel2 contains 3 Panels that are made visible based on which item is selected in the TreeView. I want these 3 Panels to always be completely visible (I'm planning to limit the expansion of the splitter so the form cannot expand beyond the screen), is this possible or should I just create my own control and adjust the size of things using the MouseDown, MouseUp, and MouseMove events?

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

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

发布评论

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

评论(3

情何以堪。 2024-09-21 14:42:28

无需创建自己的表单:SplitContainer 有一个属性:“FixedPanel”
选择 SplitContainer,然后在布局部分中查看“FixedPanel”,将其设置为您想要保持宽度或高度恒定的面板(取决于面板布局)。

以编程方式:

sc.FixedPanel = FixedPanel.Panel1; //Or Panel2

请参阅:

拆分容器,制作固定面板

SplitContainer 中的固定面板高度

There's no need to create your own form: SplitContainer has a property: "FixedPanel"
Select the SplitContainer and in the Layout section look at "FixedPanel" Set it to the panel you want to stay constant in width or height (depending on the panel layout).

Programatically:

sc.FixedPanel = FixedPanel.Panel1; //Or Panel2

See:

Splitcontainer, Make a fixed panel

Fixed Panel Height in a SplitContainer

隔纱相望 2024-09-21 14:42:28

您无法在 SplitContainer 中设置面板的高度属性;但您可以捕获窗体上的 Resize 事件并设置 splitterDistance。 SplitContainer 将为您调整另一个面板。这是我下面工作中的一段代码,它成功地迫使 Panel1 在表单调整大小时保持相同的大小。希望这有助于

Private Sub frmApp_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) 处理 MyBase.Resize
Me.SplitContainer1.SplitterDistance = 140
结束子

You can't set the height property of a panel in SplitContainer; but you can capture the Resize event on the form and set the splitterDistance. The SplitContainer will adjust the other panel for you. This is piece of code from my work below and it successfully forced Panel1 to stay the same size when the form resize. Hope this helps

Private Sub frmApp_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
Me.SplitContainer1.SplitterDistance = 140
End Sub

忆梦 2024-09-21 14:42:28

我最终创建了自己的控件。

I ended up creating my own control.

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