Common Practice - SplitContainer
Asked Answered
C

3

5

Is it common practice to have a SplitContainer control, and then add another SplitContainer to it, and then add another, and another...?

It just seems like there should be a better way, I mean, once you get up to about 3 or 4 SplitContainers, you literally run out of space to work in, in Designer view.

Chaing answered 16/5, 2011 at 1:25 Comment(0)
F
8

If you find yourself nesting too many SplitContainers, it's time to drop down a level and look at the Splitter control itself. Assume for a minute that we're talking about a bunch of horizontal rows like this:

+-----------+
| Content 1 |
+-----------+
| Content 2 |
+-----------+
| Content 3 |
+-----------+

Take the contents of your Content 1 section, and put them in some kind of container, such as a panel. Dock that panel to the top of the form. Now drag a Splitter control onto the form. It will probably start out oriented vertically, so change its docking to be "Top", and it will stick itself to the bottom of the Content 1 container. Now add another container to hold the "Content 2" stuff, dock it to the top. Add another Splitter, and dock it to the top. Finally, add the "Content 3" stuff in a panel, and set its docking behavior to "Fill". You can stack as many Splitters up as you want, this way.

By docking the splitters to the top, or to the bottom, they will figure out at runtime who their neighbors are, and how to resize them. This behavior is controlled entirely by the controls' "Z-Order", which should translate roughly as "the order the controls were added to the form" for most people. You can see and manipulate this in the "Document Outline" view, (View -> Other Windows -> Document Outine, or Ctrl-W, U). Experiment a little with an empty form, and it will all make sense.

Facilitate answered 16/5, 2011 at 11:59 Comment(2)
Thank you @Mel, this turned out to be much easier and quicker to work with than the SPlitContainer Control. :)Illnatured
I still use SplitContainers for most things, since they're pretty convenient for the simple cases. When you start getting into 3 or 4 panels, though, they don't quite cut it.Facilitate
L
4

Nope, that's the way it works.

Tell your boss you require a larger monitor.

Leavening answered 16/5, 2011 at 1:47 Comment(0)
G
1

You could use the TableLayoutContainer.

Geometrid answered 16/5, 2011 at 4:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.