I've added a splitContainer to my form but I can't figure out how to set the splitContainer.panel2 width and height? I have two panels: splitContainer.Panel1 and splitContainer.panel2.

I have the splitContainer.Dock set to Left.

When I try to set the splitContainer.panel2 width I get an error saying to set the Distance. The Distance is from the left or top. I have the splitContainer dock set to Left but that's for the main splitContainer.panel1 isn't it?

So how do I set splitContainer.panel2 width and height?

Thank you...

Recommended Answers

All 6 Replies

A splitContainer is one unit with a Size property. Work with the SplitterDistanc property to manipulate each panel size.

I get that concept. I have my splitContainer.Dock property set to .Left and I've set the .SplitterDistance to 200 which nicely sizes in a left-right manner.

So, how can I use .SplitterDistance to set .Height if .Dock is set to .Left? This is where I'm confused.

If you want to control the Height set the Dock property of the panel to Top.

So I gather that I can only control the Height or the Width? If I set .Dock to Top then I'm controlling the .Height and the width automatically sizes to match the container width my splitContainer is inside?

If I set .Dock to Left, then I can control the width of the two panels via the .SplitterDistance and the splitContainer Height fills in vertically.

Does that sound right?

If you want to control both, set the Dock property of the SplitPanel to None.

Bingo!!! That did it...thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.