tags:

views:

224

answers:

4

I want to add a collapse/expand capability to a Windows Form.

Is this built into the splitter control? Is there a tutorial for this UI technique?

The immediate project I'm thinking of is a simple UI, Windows Forms. It has 3 panels, one oriented at the top, one in the middle and one at the bottom. I want to be able to collapse the middle panel completely, but yet keep it available for expansion.


I saw the SO question,
Looking for a Visual Studio toolbox style navigation for desktop applications

..and that's more about a toolbox with draggable components. I don't care about the draggable capability. What I want is a collapsible form region, the way the toolbox and other elements in VS are collapsible, the way the IE8 favorites panel is pinnable or collapsible.

+1  A: 

use System.Windows.Forms.SplitContainer

inside the SplitContainer panel you can use a FlowLayoutPanel or a custom toolbox

serhio
+2  A: 

I'd use a FlowLayoutPanel.

It will do exactly what you describe.

Add 3 panels to it. In the 2nd panel, add another FlowLayoutPanel. Inside that one, add a label and YourCollapsablePanel. When clicking the label, toggle the visibility of the panel below it.

If you mean for it to collapse like the Toolbox does in visual studio then the DockPanelSuite will do that for you. You can turn off the ability to drag and dock the windows elsewhere.

hometoast
+1  A: 

Have you looked at the DockPanel Suite?

Jeremy Wiebe
+2  A: 

Define a FlowLayout panel and add your panels to that and structure them to your needs.

In your middle panel add a small contol button with an image of collapse to begin with. In the click event set the visibility to false, flip the image to expand button and vice versa .

[Edited. Flow layout will make things easier]

SKG