开发者

Common Practice - SplitContainer

开发者 https://www.devze.com 2023-03-06 07:13 出处:网络
Is it common practice to have a SplitContainer control, and then add another SplitContainer to it, and then add another, and another...?

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.


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.


Nope, that's the way it works.

Tell your boss you require a larger monitor.


You could use the TableLayoutContainer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号