SplitContainer 中的固定面板高度
我有一个 WinForm,其顶部包含一个 BindingNavigator,一个 splitContainer,其下方有两个水平面板。 splitContainer 填充了 BindingNavigator 未占用的空间。
我想将底部面板设置为固定高度,例如 100 像素,并让顶部面板填充其余空间。
这是我当前的代码:
kundeteamSplitContainer.SplitterDistance = kundeteamSplitContainer.Height - 100;
我本以为这会将分割器距离动态设置为始终比总高度小 100 个像素,使底部面板占据剩余的 100 个像素。但这并没有按预期工作,因为当我在运行时调整表单大小时,底部面板不断改变大小。
编辑:如果可能的话,我会坚持使用 splitContainer 。已经实现了一系列与隐藏/显示底部面板相关的功能,我不想再做这项工作。
I have a WinForm containing a bindingNavigator at the top and a splitContainer with two horisontal panels below it. The splitContainer fills the space not occupied by the bindingNavigator.
I would like to set the bottom panel to a fixed height of, say 100 pixels, and have the top panel fill the rest of the space.
This is my current code:
kundeteamSplitContainer.SplitterDistance = kundeteamSplitContainer.Height - 100;
I would have thought that this would set the splitter distance dynamically to 100 pixels less than the total height at all times, making the bottom panel occupy the remaining 100 pixels. This does not work as intended though as the bottom panel keeps changing size when I re-size the form at run-time.
EDIT: I am sticking with the splitContainer if at all possible. Got a bunch of functionality related to hiding/showing the bottom panel already implemented and I don't want to do that work again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
设置固定面板 属性给你想要保持相同大小的面板。
Set the FixedPanel property to the panel you want to remain the same size.
正如李所指出的:
这工作起来是这样的:
As pointed out by Lee:
This works like this:
将 isSplitterFixed 属性设置为“True”的最佳方法
Best way you can set isSplitterFixed Property to "True"
我会使用 TableLayoutControl 而不是 Splitter 来完成类似的事情。
I'd use a TableLayoutControl for something like this rather than a Splitter.
如果您只想显示和禁用面板(不自动调整大小,用户不调整大小),请在 Sakkle 的代码中添加以下行:
If you want only show and disable the panel (no automatic resize, no resize by the user) add to the code by Sakkle this line: