Click here to Skip to main content
11,922,641 members (57,769 online)
Click here to Skip to main content
Add your own
alternative version


372 bookmarked


, 27 Nov 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
Outlook 2007 styled expandable and collapsible panels and panel collections for grouping collections of controls.


The XPander library offers the option to store many user controls in one single document formula. They are optionally visible or non-visible, expanded or collapsed. The controls provide optically the Microsoft Outlook 2007 style with black, silver and blue color schemes. They also provide other styles. The included ToolStripRenderers offer some other opportunities. All the controls support visual designer, smart tag and RightToLeft features. It contains the following components.


The panel is a control that contains other controls. You can use a panel to group collections of controls such as the XPanderPanelList control. On top of the panel, there is the captionbar. This captionbar may contain an image and text. According to its dockstyle and properties, the panel is collapsible and/or closable.





The XPanderPanelList contains XPanderPanels, which are represented by XPanderPanel objects that you can add through the XPanderPanels property. The order of XPanderPanel objects reflects the order in which the xpanderpanels appear in the XPanderPanelList control.



XPanderPanel controls represent the expandable and collapsible panels in XPanderPanelList. The XpanderPanel is a control that contains other controls. You can use an XPanderPanel to group collections of controls such as the XPanderPanelList. The order of xpanderpanels in the XPanderPanelList.XPanderPanels collection reflects the order of xpanderpanels controls. To change the order of tabs in the control, you must change their positions in the collection by removing them and inserting them at new indexes. You can change the xpanderpanel's appearance. For example, to make it appear flat, set the CaptionStyle property to CaptionStyle.Flat.

On top of the XPanderPanel, there is the captionbar. This captionbar may contain an image and text. According to its properties, the panel can be closed.



This represents a splitter control that enables the user to resize docked controls. As different from the System.Windows.Forms.Splitter, the splitter supports a transparent background color.


A splitter can be attached to a panel. If the visibility of the panel changes, the visibility of the splitter changes too.


All the panelcolors and properties are customizable and changeable with the visual designer.



If you want to expand a XPanderPanel in the Visual Designer, please click the captionbar.


When the RightToLeft property value is set to RightToLeft.Yes, the horizontal alignment of the control's elements are reversed.


Using the Code

Right click on the toolbox and choose add/remove items..., there you browse for the BSE.Windows.Forms.dll and press OK. All the controls will be added in the ToolBox under "My User Controls". Set BSE.Windows.Test as StartUp Project.

Using the RightToLeft Feature in the Test Sample

Open the Program.cs file in the BSE.Windows.Test project and remove the following comments:

static void Main()
    //// if you want to use the RightToLeft demo,
    //// please remove these comments
    //CultureInfo currentCulture = new CultureInfo
    // (BSE.Windows.Test.Properties.Settings.Default.Language);
    //Thread.CurrentThread.CurrentCulture = currentCulture;
    //Thread.CurrentThread.CurrentUICulture = currentCulture;


    //// if you want to use the RightToLeft demo,
    //// please remove these comments
    //using (CCountrySelectionForm form = new CCountrySelectionForm())

    Application.Run(new Form1());

Select the ar-EG culture name for the Arabic (Egypt) culture:


Class Diagrams



Panel and XPanderPanel


Code Examples

Using the ToolstripProfessionalRenderer and the PanelsettingsManager at runtime:

public class Form2 : Form
	private BSE.Windows.Forms.Panel panel1;
	public Form2()
		// Create and initialize a Panel.
		this.panel1 = new BSE.Windows.Forms.Panel();
		this.panel1.Text = "panel1";
		// Set the panel background.
		this.panel1.ShowTransparentBackground = false;
		// Set the panel's DockStyle to DockStyle.Fill
		this.panel1.Dock = DockStyle.Fill;
		// Add the panel to the form

		// Create and initialize a ToolStripProfessionalRenderer.
		ToolStripProfessionalRenderer renderer = 
			new BSE.Windows.Forms.Office2007Renderer();
		// Add it to the ToolStripManager.Renderer
		ToolStripManager.Renderer = renderer;

		// Get the ProfessionalColorTable colorTable for the current renderer.
		BSE.Windows.Forms.ProfessionalColorTable colorTable = 
		    renderer.ColorTable as BSE.Windows.Forms.ProfessionalColorTable;
		if (colorTable != null)
			// Get the PanelColors panelColorTable for the 
			// current  colortable.
			BSE.Windows.Forms.PanelColors panelColorTable = 
			if (panelColorTable != null)
				// Set the panel properties for the form 
				// controls collection
				SetPanelProperties(this.Controls, panelColorTable);

Adaption of the Panel Colors

Create a colortable that derives from BSE.Windows.Forms.PanelColors and overwrite the protected method InitColors:

public class YourPanelColors : PanelColorsOffice
    protected override void InitColors(Dictionary<panelcolors.knowncolors>, rgbTable)
        rgbTable[KnownColors.BorderColor] = Color.FromArgb(101, 147, 207);
        rgbTable[KnownColors.InnerBorderColor] = Color.White;
        rgbTable[KnownColors.PanelCaptionCloseIcon] = Color.Black;
        rgbTable[KnownColors.PanelCaptionExpandIcon] = Color.FromArgb(21, 66, 139);
        rgbTable[KnownColors.PanelCaptionGradientBegin] = 
					Color.FromArgb(227, 239, 255);
        rgbTable[KnownColors.PanelCaptionGradientEnd] = 
					Color.FromArgb(173, 209, 255);
        rgbTable[KnownColors.PanelCaptionGradientMiddle] = 
					Color.FromArgb(199, 224, 255);
        rgbTable[KnownColors.PanelContentGradientBegin] = 
					Color.FromArgb(227, 239, 255);
        rgbTable[KnownColors.PanelContentGradientEnd] = 
					Color.FromArgb(227, 239, 255);
        rgbTable[KnownColors.PanelCaptionText] = Color.FromArgb(22, 65, 139);
        rgbTable[KnownColors.PanelCollapsedCaptionText] = 
					Color.FromArgb(21, 66, 139);
        rgbTable[KnownColors.XPanderPanelBackColor] = Color.Transparent;
        rgbTable[KnownColors.XPanderPanelCaptionCloseIcon] = Color.Black;
        rgbTable[KnownColors.XPanderPanelCaptionExpandIcon] = 
					Color.FromArgb(21, 66, 139);
        rgbTable[KnownColors.XPanderPanelCaptionText] = Color.FromArgb(21, 66, 139);
        rgbTable[KnownColors.XPanderPanelCaptionGradientBegin] = 
					Color.FromArgb(227, 239, 255);
        rgbTable[KnownColors.XPanderPanelCaptionGradientEnd] = 
					Color.FromArgb(199, 224, 255);
        rgbTable[KnownColors.XPanderPanelCaptionGradientMiddle] = 
					Color.FromArgb(173, 209, 255);
        rgbTable[KnownColors.XPanderPanelFlatCaptionGradientBegin] = 
					Color.FromArgb(214, 232, 255);
        rgbTable[KnownColors.XPanderPanelFlatCaptionGradientEnd] = 
					Color.FromArgb(253, 253, 254);
}    </panelcolors.knowncolors>

Or you may set the ColorScheme property to ColorScheme.Custom and fill the CustomColors properties with your colors.


  • Thanks to Phil. Wright for his Office 2007 ToolStrip Renderer. That gave me an insight into toolstrip rendering.
  • Thanks to Bernhard Jenny for many tips.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Uwe Eichkorn
Switzerland Switzerland
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
JNDIONYSIM12-May-14 22:23
memberJNDIONYSIM12-May-14 22:23 
Questionbug ... when i add a lot of xpanderPanel in xpanderListPanel Pin
Ehsanf37-Mar-14 20:13
memberEhsanf37-Mar-14 20:13 
QuestionCaption image Pin
Member 882350017-Dec-12 8:31
memberMember 882350017-Dec-12 8:31 
BugA Bug? when i add lots of sub panel, the property of AutoScroll is failed. Pin
IcyJiang7-Aug-12 21:04
memberIcyJiang7-Aug-12 21:04 
Questiondowloading Pin
khanzzirfan15-Jun-12 20:54
memberkhanzzirfan15-Jun-12 20:54 
AnswerRe: dowloading Pin
Uwe Eichkorn18-Jun-12 3:45
memberUwe Eichkorn18-Jun-12 3:45 
BugBug Solution For XpanderPanelCollection.Insert method Pin
terminal_gr17-May-12 7:41
memberterminal_gr17-May-12 7:41 
QuestionAlpha blending... Pin
93Current6-Jan-12 0:24
member93Current6-Jan-12 0:24 
AnswerRe: Alpha blending... Pin
93Current6-Jan-12 8:20
member93Current6-Jan-12 8:20 
QuestionVB version Pin
dherrmann18-Oct-11 10:46
memberdherrmann18-Oct-11 10:46 
AnswerRe: VB version Pin
Uwe Eichkorn25-Oct-11 2:22
memberUwe Eichkorn25-Oct-11 2:22 
GeneralRe: VB version Pin
dherrmann25-Oct-11 6:44
memberdherrmann25-Oct-11 6:44 
Question.NET 4.0 Pin
Matt U.30-Aug-11 8:58
memberMatt U.30-Aug-11 8:58 
QuestionIs it or isn't it? Pin
Johnny J.2-Aug-11 14:05
memberJohnny J.2-Aug-11 14:05 
AnswerRe: Is it or isn't it? Pin
Johnny J.21-Sep-11 3:24
memberJohnny J.21-Sep-11 3:24 
Questionadd gradient to content panels? Pin
roger_2721-Jul-11 8:14
memberroger_2721-Jul-11 8:14 
QuestionExpand to left/right Direction Pin
Xennon114-Jul-11 3:16
memberXennon114-Jul-11 3:16 
QuestionChm file can't open Pin
nrdsp13-Jul-11 1:13
membernrdsp13-Jul-11 1:13 
AnswerRe: Chm file can't open Pin
Johnny J.2-Aug-11 14:06
memberJohnny J.2-Aug-11 14:06 
GeneralProblems with Install on Visual C# 2008 Express Pin
hsfan17-May-11 4:20
memberhsfan17-May-11 4:20 
GeneralMy vote of 5 Pin
rahul_raut17-May-11 1:13
memberrahul_raut17-May-11 1:13 
Great Work!
GeneralMy vote of 5 Pin
lianghuating12-May-11 18:18
grouplianghuating12-May-11 18:18 
QuestionCan I use it in commercial product? Pin
Southmountain25-Nov-10 9:27
memberSouthmountain25-Nov-10 9:27 
AnswerRe: Can I use it in commercial product? Pin
Uwe Eichkorn10-Dec-10 23:14
memberUwe Eichkorn10-Dec-10 23:14 
GeneralMy vote of 5 Pin
tubeastig28-Sep-10 21:29
membertubeastig28-Sep-10 21:29 
QuestionExpand clicking on caption not on icon Pin
romias20-Sep-10 9:27
memberromias20-Sep-10 9:27 
AnswerRe: Expand clicking on caption not on icon Pin
romias3-Oct-10 8:35
memberromias3-Oct-10 8:35 
QuestionProblem when AutoScalling Pin
mehafi17-Aug-10 1:23
membermehafi17-Aug-10 1:23 
GeneralCongrats!!! Pin
megalucaiv24-Jan-10 19:04
membermegalucaiv24-Jan-10 19:04 
QuestionHow programicly select panel in panel list Pin
mehafi24-Nov-09 23:39
membermehafi24-Nov-09 23:39 
AnswerRe: How programicly select panel in panel list Pin
Uwe Eichkorn25-Nov-09 1:06
memberUwe Eichkorn25-Nov-09 1:06 
Generaltabcontrol flickering when mouse moving Pin
zhaow71-Sep-09 18:16
memberzhaow71-Sep-09 18:16 
GeneralRe: tabcontrol flickering when mouse moving Pin
Uwe Eichkorn22-Sep-09 4:28
memberUwe Eichkorn22-Sep-09 4:28 
QuestionHeavy flickering when resizing Pin
AKDM19-Aug-09 13:30
memberAKDM19-Aug-09 13:30 
AnswerRe: Heavy flickering when resizing Pin
Uwe Eichkorn20-Aug-09 9:24
memberUwe Eichkorn20-Aug-09 9:24 
GeneralRe: Heavy flickering when resizing Pin
AKDM21-Aug-09 7:12
memberAKDM21-Aug-09 7:12 
Questionhow to implement panel collapsing? Pin
eug200726-Jul-09 4:13
membereug200726-Jul-09 4:13 
AnswerRe: how to implement panel collapsing? Pin
Uwe Eichkorn26-Jul-09 20:49
memberUwe Eichkorn26-Jul-09 20:49 
QuestionHow to change Panel color using Office2007BlueColorTable Pin
AKDM19-Jul-09 10:55
memberAKDM19-Jul-09 10:55 
AnswerRe: How to change Panel color using Office2007BlueColorTable Pin
Uwe Eichkorn19-Jul-09 22:01
memberUwe Eichkorn19-Jul-09 22:01 
GeneralThanks ! Great Work ! Pin
igetorix31-May-09 4:07
memberigetorix31-May-09 4:07 
GeneralSimply awesome !!! Pin
Tamal Saha13-May-09 20:01
memberTamal Saha13-May-09 20:01 
GeneralThanks Pin
stevesupervillain9-Mar-09 6:08
memberstevesupervillain9-Mar-09 6:08 
GeneralPanel with Autoscroll Pin
WayneSchou24-Feb-09 14:29
memberWayneSchou24-Feb-09 14:29 
QuestionUSE FREE Pin
Member 323381629-Dec-08 4:12
memberMember 323381629-Dec-08 4:12 
GeneralSaving and restoring positions Pin
Tom Holt2-Dec-08 6:05
memberTom Holt2-Dec-08 6:05 
GeneralRe: Saving and restoring positions Pin
Uwe Eichkorn2-Dec-08 11:15
memberUwe Eichkorn2-Dec-08 11:15 
QuestionHow about supportting docking and drag-drop? Pin
jeasonzhao1-Dec-08 17:23
memberjeasonzhao1-Dec-08 17:23 
AnswerRe: How about supportting docking and drag-drop? Pin
Uwe Eichkorn1-Dec-08 21:43
memberUwe Eichkorn1-Dec-08 21:43 
GeneralSo beautyful those controls,I need another version! Pin
topmvp17-Nov-08 20:24
membertopmvp17-Nov-08 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.1 | Last Updated 27 Nov 2008
Article Copyright 2007 by Uwe Eichkorn
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid