C# Prevent resizing of both splitcontainer panels
I have a Split开发者_高级运维Container and was wondering how I would go about setting a static size for both panels and prevent the user from having the ability to resize the panels. Would FixedPanel be the solution? From what I read, I don't think it is.
I think you are just looking for the "IsSplitterFixed" property.
The title of this question is misleading. There are more than one correct answers that satisfy the title of this question, in spite of the chosen answer.
For clarification:
FixedPanel
is what you're looking for to have one panel keep its size when resizing the SplitContainer. According to the description in the Properties window:
FixedPanel
Indicates that a particular SplitContainer's Panel should remain fixed in size during resize events
IsSplitterFixed
is just a way to temporarily prevent the user from moving the splitter. The panels still resize in proportion to the SplitContainer's size.
I am really curious why you would want to use split container if you don't want the user to resize it
However in case you want to prevent one of the panels from auto-resizing with the parent container
It is the "Fixed panel" property of Split container.
If you don't want to allow the user to resize the panels, do not use an SplitContainer.
Simply use panels, and add a 2px width panel to simulate the separator.
- PanelContainer -> Will contain PanelA, PanelB and PanelC
- PanelA (left panel) -> Dock it to left
- PanelB (separator) -> setup to have 2px width
- PanelC (right panel) -> Dock it to fill
Then, you can change the size of the panels as you want in design mode, and the user will not be able to resize the panels.
精彩评论