Keeping One Split Container Panel Fixed Width?
I can't seem to figure out how to keep a panel's wi开发者_StackOverflow社区dth fixed in a Split Container in a WinForm.
Any suggestions?
property SplitterPanel.FixedPanel
- set one of the panels to fixed size
property SplitterPanel.IsSplitterFixed
- set to true
In order to make panel1
fixed
In the properties of the SplitContainer
, set the FixedPanel
property to Panel1
.
Then, set the SplitDistance
and Panel1MinSize
to the same value.
Fix Panel (Lock Panel):
SplitContainer.FixedPanel = FixedPanel.Panel
If you'd keep one panel's size fixed, there is no logical way to move the splitter. Since you can't move the splitter, it just doesn't make sense to use a SplitContainer anymore. Use two Panel controls.
It depends what you want.
FixedPanel
let's the user resize the panel but it won't resize automatically when the control is resized.
IsSplitterFixed
will disable the splitter, but it will still resize automatically when the control is resized.
If you use both then it will be totaly fixed. But then you're better off using two panels like Hans said.
// from Microsoft documentation similar to Dmitri answer:::::::::::
// if make panel1 fixed:
mySplitContainer.FixPanel = System.Windows.Forms.FixedPanel.Panel1;
// if make panel2 fixed (in this case can't use fixed splitter distance):
mySplitContainer.FixPanel = System.Windows.Forms.FixedPanel.Panel2;
// and to be safe set the appropriate panel min size for the splitcontainer too;
精彩评论