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.
The SplitContainer control lets you create complex user interfaces; often, a selection in one panel determines what objects are shown in the other panel. This arrangement is very effective for displaying and browsing information.
Windows Forms Splitter controls are used to resize docked controls at run time. The Splitter control is often used on forms with controls that have varying lengths of data to present, like Windows Explorer, whose data panes contain information of varying widths at different times.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With