sooprise
sooprise

Reputation: 23187

Keeping One Split Container Panel Fixed Width?

I can't seem to figure out how to keep a panel's width fixed in a Split Container in a WinForm.

Any suggestions?

Upvotes: 39

Views: 50503

Answers (6)

Pratik Mistry
Pratik Mistry

Reputation: 121

Fix Panel (Lock Panel):

SplitContainer.FixedPanel = FixedPanel.Panel

Upvotes: 12

AlexDev
AlexDev

Reputation: 4717

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.

Upvotes: 3

gg89
gg89

Reputation: 380

// 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;

Upvotes: 1

JustCode
JustCode

Reputation: 141

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.

Upvotes: 14

Dmitri
Dmitri

Reputation: 1101

property SplitterPanel.FixedPanel - set one of the panels to fixed size

property SplitterPanel.IsSplitterFixed - set to true

Upvotes: 108

Hans Passant
Hans Passant

Reputation: 941665

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.

Upvotes: 6

Related Questions