Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed Panel Height in a 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.

like image 375
Sakkle Avatar asked Sep 03 '09 14:09

Sakkle


4 Answers

As pointed out by Lee:

Set the FixedPanel property to the panel you want to remain the same size.

This works like this:

teamSplitContainer.SplitterDistance = teamSplitContainer.Height - 100;
teamSplitContainer.FixedPanel = FixedPanel.Panel2;
like image 173
Sakkle Avatar answered Nov 09 '22 18:11

Sakkle


Best way you can set isSplitterFixed Property to "True"

Property Window for splitcontainer

like image 24
Sachith Wickramaarachchi Avatar answered Nov 09 '22 17:11

Sachith Wickramaarachchi


Set the FixedPanel property to the panel you want to remain the same size.

like image 27
Lee Avatar answered Nov 09 '22 18:11

Lee


I'd use a TableLayoutControl for something like this rather than a Splitter.

like image 2
MartW Avatar answered Nov 09 '22 18:11

MartW