Window form Expander
I wrote a expander using WinForm in C#
The source code is available here.
The Expander is divided in two regions: Header and Content. They take a Control, so you can create your own header control and put any control that you want into the content region.
Here is a image of a Expander created using the Expander control:

The header and the content are basic Labels.
The code to create this expander is the following:
Expander expander = new Expander();
expander.Size = new Size(250, 400);
expander.Left = 350;
expander.Top = 10;
expander.BorderStyle = BorderStyle.FixedSingle;
ExpanderHelper.CreateLabelHeader(expander, "Header", SystemColors.ActiveBorder, Properties.Resources.Collapse, Properties.Resources.Expand);
Label labelContent = new Label();
labelContent.Text = "This is the content part.\r\n\r\nYou can put any Controls here. You can use a Panel, a CustomControl, basically, anything you want.";
labelContent.Size = new System.Drawing.Size(expander.Width, 80);
expander.Content = labelContent;
this.Controls.Add(expander);
This sample use the ExpanderHelper class to create a header label.
You can create your own header control. The next sample create a Label and connect the Label.Click event to toggle the expander and change the background color depending on the expander state.
Expander expander = new Expander();
expander.Size = new Size(250, 120);
expander.Left = 350;
expander.Top = 230;
expander.BorderStyle = BorderStyle.FixedSingle;
Label headerLabel = new Label();
headerLabel.Text = "Click me";
headerLabel.AutoSize = false;
headerLabel.Font = new Font(headerLabel.Font, FontStyle.Bold);
headerLabel.TextAlign = ContentAlignment.MiddleLeft;
headerLabel.BackColor = SystemColors.ActiveBorder;
headerLabel.Click += delegate
{
expander.Toggle();
if (expander.Expanded)
headerLabel.BackColor = SystemColors.ActiveBorder;
else
headerLabel.BackColor = SystemColors.ActiveCaption;
};
expander.Header = headerLabel;
Label labelContent = new Label();
labelContent.Text = "You are not limited to use the ExpanderHelper to create your header. Here is a example with a custom code and custom click event handler that change the header backcolor when the expander state change.";
labelContent.Size = new System.Drawing.Size(expander.Width, 75);
expander.Content = labelContent;
this.Controls.Add(expander);
Expander State
The expander offer 2 events: StateChanging and StateChanged.
You can use the StateChanging to prevent the expander to collapse or to expand.
A other rich panel


Does this require the 4.0 framework or can it be used with a lower version?
I created the classes using VS2010 and .NET 4. But you can create a new project in a other version of .net and copy the classes into your new project. It should work.
Works ONLY on Framework 4.0
This is very helpful, thank you!
Actually it works on .NET 3.5 as well. It just needs the Microsoft.CSharp reference removed and the resources file deleted and rebuilt.
its not wokring on dotnet 3.5