I'm not sure this is more or less efficient or easier to code than Les' example, but the attached project uses the StrataFrameCollapsableContainerLinkManager, which contains the logic to automatically collapse all other containers.
There are a couple of things to note:
- The HeaderHeight isn't the height the header...or at least not the part that is shown when it is collapsed. It is the height of the header plus the action area. I.e. if you set the ActionAreaHeight to 0, then HeaderHeight is the height of the bit shown when collapsed.
- You can't use Dock = Fill. No idea why, but flow layout containers (as I recall) don't like it. Anchoring isn't so hot either. Thus, you have to manage heights if you are going to handle resizing. The project includes an example of how to manage height changes. Width changes are left for your own experimentation
- Setting the Height of a collapsed container is bad if the container is actually collapsed (IsBodyShown = false). It immediately sets the height of the container (and renders it), but leaves the IsBodyShown property alone. Thus, you now have a collapsed container that is not collapsed. Worse, since the IsBodyShown property is already false, you can't re-collapse is using that property.
- Set things up in the constructor. The controls are all created but aren't actually windows controls yet (no handles, etc.), so you can set heights and IsBodyShown here and it will work. If you wait for the form Load, things get wanky.
- In order to manage resizing, you'll need to handle each containers Opened event, then set the correct height based on the current flowlayoutpanel height. The project includes an example of this. The Opening event doesn't work, due to weirdness between the Height property and the IsBodyShown property...or something like that.
- If you don't need to handle resizing, its really easy to set this up. Example included there also.
- By default, the link manager allows all the containers to be collapsed. Not entirely sure how to stop the last one from collapsing. I'd guess that how easy is it do do that depends on how link manager does the collapsing.
- The collapsible container and the link manager are not on the toolbar by default (there still beta), so if you want to drag and drop them on a form, you'll need to add them to the toolbar manually.
Attached project includes a single form with examples showing resizing (resize the form, flowlayoutpanel anchored to top and bottom) and one without resizing.
Hope this helps!