HypernovaDesktop Components · docs
Binarymission
WinForms › Header Control › BinaryHeaderControl

BinaryHeaderControl

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.NavigationControls

A panel with an Outlook-style caption band – and an optional footer band – drawn across one of its edges, used to give a group of controls a titled, collapsible, colour-themed frame such as a navigation pane, a task pane or a "Folders" box.

public partial class BinaryHeaderControl : Panel

Inherits from / implements: Panel

Remarks

What it is for

Drop the controls of one pane – a tree of mail folders, a list of tasks, a set of filter options – onto a BinaryHeaderControl and they get a titled frame: a gradient caption band with an optional icon, a gradient client area behind them, a border, and optionally a footer band, a drop shadow, and a button at the end of the caption that either collapses the pane to its caption or opens a menu of commands for it.

Key concepts

  • The bands are outside the client area. The caption and the footer are drawn in the window's frame, so docked and anchored children start below the caption and stop above the footer without any margin of your own. HeaderLocation puts the caption along the top, bottom, left or right edge; on the left and right the band and its text are turned on their side.
  • One button, two jobs. The button at the end of the caption is either the collapse button (EnableCollapseExpandButton, on by default) or the context menu button (EnableHeaderContextMenu). Turning either on turns the other off.
  • Colour schemes. ColorScheme sets the caption, footer, background and border colours in one go. Choose ColorScheme.None to keep colours of your own.
  • No scrolling of its own. AutoScroll is always false. Put a BinaryScrollablePanel inside the control and the controls on that panel when the content can be longer than the pane.

How to use it

Set HeaderText (and HeaderIcon or HeaderImage), choose a ColorScheme, add the pane's controls, and handle HeaderClicked, FooterClicked or HeaderContextMenuAboutToBeDisplayed as needed.

Appearance

HeaderFooterDrawingStyle chooses between a plain two-colour gradient and an Office style two-tone band. The caption and footer each have a gradient (StartColorForHeaderRendering, EndColorForHeaderRendering, HeaderGradientDrawingDirection, and the footer equivalents), a font, a text colour and an optional inner border (DrawBorderAround). The client area is painted with StartColorForBackgroundRendering to EndColorForBackgroundRendering. ShouldDrawDropShadow adds a soft shadow along the bottom and right edges.

Band heights are in logical pixels (1/96 inch) and are scaled with the display; a band is never made shorter than one line of its caption font.

Examples

A "Mail folders" pane docked down the left of a form, with a footer, a scrolling folder list and a context menu of folder commands.

using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.NavigationControls;

public class MailForm : Form
{
    private readonly ListBox folders = new ListBox();
    private readonly ToolStripMenuItem emptyDeletedItems = new ToolStripMenuItem("Empty Deleted Items");

    public MailForm()
    {
        Text = "Mail";
        Size = new Size(900, 600);

        var menu = new ContextMenuStrip();
        menu.Items.Add("New folder...");
        menu.Items.Add(emptyDeletedItems);

        var pane = new BinaryHeaderControl
        {
            Dock = DockStyle.Left,
            Width = 240,
            ColorScheme = ColorScheme.Blue,
            HeaderFooterDrawingStyle = HeaderFooterDrawingStyle.OfficeStyle,
            HeaderText = "Mail folders",
            HeaderCaptionFont = new Font("Segoe UI", 10f, FontStyle.Bold),
            HeaderTextForeColor = Color.Navy,
            EnableHeaderContextMenu = true,     // the caption button opens HeaderContextMenuStrip
            HeaderContextMenuStrip = menu,
            DrawFooter = true,                  // set before FooterText: the text is ignored without a footer
            FooterText = "3 unread in Inbox",
            ShouldDrawDropShadow = true,
        };

        // The pane does not scroll by itself; a BinaryScrollablePanel fills its client area.
        var scroller = new BinaryScrollablePanel();
        folders.Dock = DockStyle.Fill;
        folders.Items.AddRange(new object[] { "Inbox", "Drafts", "Sent Items", "Deleted Items", "Archive" });
        scroller.Controls.Add(folders);
        pane.Controls.Add(scroller);

        pane.HeaderClicked += (s, e) => folders.Focus();
        pane.HeaderContextMenuAboutToBeDisplayed += OnFolderMenuOpening;

        Controls.Add(pane);
    }

    private void OnFolderMenuOpening(object sender, ref bool cancel)
    {
        emptyDeletedItems.Enabled = (string)folders.SelectedItem == "Deleted Items";
    }
}

See also

Members at a glance

Constructors
BinaryHeaderControlInitialises a new BinaryHeaderControl with the ColorScheme.Blue colour scheme, the caption across the top and the collapse button showing.
Properties
AutoScrollGets whether the client area scrolls; it never does.
BackgroundGradientDrawingDirectionGets or sets the direction in which the client area's background gradient runs.
BorderColorGets or sets the colour of the border drawn round the whole control.
BorderStyleGets the standard Windows border style, which is always BorderStyle.None.
BorderWidthGets or sets the thickness of the border drawn round the whole control.
ColorSchemeGets or sets the built-in palette the caption, footer, background, border and context menu button are drawn in.
ContextMenuArrowColorGets or sets the colour of the arrow inside the built-in context menu button.
ContextMenuEllipseColorGets or sets the colour of the round body of the built-in context menu button.
ContextMenuImageTypeGets or sets which picture is drawn as the context menu button: the built-in round button, your icon or your bitmap.
ContextMenuTypeGets or sets which of the two menu properties the context menu button opens.
ControlIsInExpandedStateGets or sets whether the control is expanded, as opposed to collapsed to its caption.
CustomContextMenuButtonImageTransparencyColorGets or sets the colour in CustomImageForContextMenuButton that is made transparent, so that the caption shows through the picture's background.
CustomIconForContextMenuButtonGets or sets the icon drawn as the context menu button when ContextMenuImageType is ContextMenuButtonImageType.Icon.
CustomImageForContextMenuButtonGets or sets the picture drawn as the context menu button when ContextMenuImageType is ContextMenuButtonImageType.Bitmap.
DisplayRectangleGets the area available to the hosted controls, in client coordinates.
DrawBorderAroundGets or sets which bands – the caption, the footer, both or neither – have a border drawn just inside their edges.
DrawFooterGets or sets whether a footer band is drawn along the edge opposite the caption.
DropShadowColorGets or sets the colour of the drop shadow.
DropShadowDepthGets or sets how far the drop shadow reaches beyond the frame.
DropShadowOpacityGets or sets how dark the drop shadow is where it is strongest, next to the frame.
EnableCollapseExpandButtonGets or sets whether the caption shows a round button that collapses the control to its caption and expands it again.
EnableHeaderContextMenuGets or sets whether the caption shows a round button that opens a menu of commands for the pane.
EndColorForBackgroundRenderingGets or sets the colour the client area's background gradient ends with.
EndColorForFooterRenderingGets or sets the colour the footer band's gradient ends with.
EndColorForHeaderRenderingGets or sets the colour the caption band's gradient ends with.
ExpandCollapseCircleFillColorGets or sets the colour of the round body of the collapse button.
ExpandCollapseUpDownArrowsFillColorGets or sets the colour of the double arrow on the collapse button, which points up while the control is expanded and down while it is collapsed.
FooterBorderColorGets or sets the colour of the border drawn inside the footer band.
FooterBorderThicknessGets or sets the thickness of the border drawn inside the footer band.
FooterCaptionFontGets or sets the font of the footer text.
FooterCaptionHeightGets or sets the depth of the footer band – its height along the bottom or top, its width down the left or right.
FooterGradientDrawingDirectionGets or sets the direction in which the footer band's gradient runs.
FooterTextGets or sets the text shown in the footer band – a status line such as a count of items.
FooterTextForeColorGets or sets the colour of the footer text.
FooterTextStringFormatGets or sets how the footer text is aligned, wrapped and trimmed.
HeaderBitmapTransparencyColorGets or sets the colour in HeaderImage that is made transparent, so that the caption's gradient shows through the picture's background.
HeaderBorderColorGets or sets the colour of the border drawn inside the caption band.
HeaderBorderThicknessGets or sets the thickness of the border drawn inside the caption band.
HeaderCaptionFontGets or sets the font of the caption text.
HeaderCaptionHeightGets or sets the depth of the caption band – its height when it runs along the top or bottom, its width when it runs down the left or right.
HeaderContextMenuGets or sets the menu the context menu button opens when ContextMenuType is ContextMenuType.ContextMenu.
HeaderContextMenuGets or sets the menu the context menu button opens when ContextMenuType is ContextMenuType.ContextMenu.
HeaderContextMenuStripGets or sets the menu the context menu button opens.
HeaderFooterDrawingStyleGets or sets how the caption and footer bands are filled: a plain gradient, or an Office-style two-tone band.
HeaderGradientDrawingDirectionGets or sets the direction in which the caption band's gradient runs.
HeaderIconGets or sets the icon drawn at the start of the caption, before the text.
HeaderImageGets or sets the picture drawn at the start of the caption, before the text, when an icon will not do.
HeaderImageTypeGets or sets which picture, if any, is drawn at the start of the caption.
HeaderLocationGets or sets which edge of the control the caption band runs along.
HeaderTextGets or sets the title shown in the caption band.
HeaderTextForeColorGets or sets the colour of the caption text.
HeaderTextStringFormatGets or sets how the caption text is aligned, wrapped and trimmed.
ShouldDrawDropShadowGets or sets whether a soft shadow is drawn along the control's bottom and right edges, lifting the pane off the form.
SizeGets or sets the size of the control, including its caption, footer, border and drop shadow.
StartColorForBackgroundRenderingGets or sets the colour the client area's background gradient starts with – the area behind the hosted controls.
StartColorForFooterRenderingGets or sets the colour the footer band's gradient starts with.
StartColorForHeaderRenderingGets or sets the colour the caption band's gradient starts with.
UseAntiAliasingAsHeaderCaptionTextRenderingHintGets or sets whether the caption text is drawn with plain anti-aliasing rather than grid-fitted anti-aliasing.
UseCustomImageForContextMenuButtonGets or sets whether the context menu button is drawn with a picture of your own instead of the built-in round button.
Methods
OnFontChangedRaises the Control.FontChanged event, and passes the new font on to any caption font that has not been set explicitly.
OnPaintPaints the client area's background gradient, raises the Control.Paint event, and redraws the caption, footer and border.
OnPaintBackgroundDoes nothing: the whole client area is painted in OnPaint, which avoids flicker.
OnResizeRaises the Control.Resize event after redrawing the caption, footer and border for the new size.
PerformCollapseExpandCollapses the control to its caption, as clicking the collapse button does.
WndProcProcesses the window messages that size, paint and hit test the caption and footer, and turns clicks on them into HeaderClicked, FooterClicked, a collapse or the context menu.
Events
FooterClickedOccurs when the footer band is clicked.
HeaderClickedOccurs when the caption band is clicked.
HeaderContextMenuAboutToBeDisplayedOccurs when the context menu button in the caption is clicked, just before the menu opens.

Constructors

BinaryHeaderControl

public BinaryHeaderControl() : base()

Initialises a new BinaryHeaderControl with the ColorScheme.Blue colour scheme, the caption across the top and the collapse button showing.

Remarks

The caption and footer text are centred, on one line, and trimmed with an ellipsis when they do not fit. Both caption fonts follow the control's Control.Font until you set one.

Properties

AutoScroll

public new bool AutoScroll

Gets whether the client area scrolls; it never does.

Value
Always false.
Remarks

To scroll the pane's content, add a BinaryScrollablePanel to the control and put the child controls on the panel. At run time the panel fills the client area and scrolls when its content is larger.

See also

BackgroundGradientDrawingDirection

public LinearGradientMode BackgroundGradientDrawingDirection

Gets or sets the direction in which the client area's background gradient runs.

Value
The default is Vertical: from StartColorForBackgroundRendering at the top to EndColorForBackgroundRendering at the bottom.

BorderColor

public Color BorderColor

Gets or sets the colour of the border drawn round the whole control.

Value
The default comes from the ColorScheme: RGB(128, 167, 225) for the default ColorScheme.Blue scheme.
Designer category
Color
Remarks

While ColorScheme is anything other than ColorScheme.None, choosing a scheme and setting StartColorForHeaderRendering both overwrite this colour; set it after them.

See also

BorderStyle

public new BorderStyle BorderStyle

Gets the standard Windows border style, which is always BorderStyle.None.

Value
Always BorderStyle.None.
Remarks

The control draws its own border; use BorderColor and BorderWidth to change it.

BorderWidth

public int BorderWidth

Gets or sets the thickness of the border drawn round the whole control.

Value
The thickness in pixels. The default is 2. Values of 1 or less are stored as 2.
Remarks

The border is part of the frame, so a thicker border makes the client area smaller. Unlike the band heights, this width is not scaled with the display.

See also

ColorScheme

public ColorScheme ColorScheme

Gets or sets the built-in palette the caption, footer, background, border and context menu button are drawn in.

Value
The default is ColorScheme.Blue.
Default
Blue
Remarks

Choosing a scheme overwrites StartColorForHeaderRendering, EndColorForHeaderRendering, the background and footer gradient colours, BorderColor, ContextMenuEllipseColor and ContextMenuArrowColor. ColorScheme.None leaves them as they are: choose it when you set those colours yourself, and set it before them.

The scheme is passed on to every BinaryScrollablePanel the control hosts directly; other child controls are left as they are.

Example
// A corporate palette of your own: switch the schemes off first, then set the colours.
ordersPane.ColorScheme = ColorScheme.None;
ordersPane.StartColorForHeaderRendering = Color.FromArgb(0, 84, 147);
ordersPane.EndColorForHeaderRendering = Color.FromArgb(96, 160, 214);
ordersPane.HeaderTextForeColor = Color.White;
ordersPane.BorderColor = Color.FromArgb(0, 84, 147);
See also

ContextMenuArrowColor

public Color ContextMenuArrowColor

Gets or sets the colour of the arrow inside the built-in context menu button.

Value
The default is Color.White; every ColorScheme other than ColorScheme.None sets it back to white.
Designer category
Header rendering
Remarks

Used while the built-in button is drawn: EnableHeaderContextMenu is on and no custom picture is in use (see UseCustomImageForContextMenuButton and ContextMenuImageType).

See also

ContextMenuEllipseColor

public Color ContextMenuEllipseColor

Gets or sets the colour of the round body of the built-in context menu button.

Value
The default comes from the ColorScheme: RGB(128, 167, 225) for the default ColorScheme.Blue scheme.
Designer category
Header rendering
Remarks

Used while the built-in button is drawn: EnableHeaderContextMenu is on and no custom picture is in use. Choosing a ColorScheme other than ColorScheme.None overwrites the colour.

See also

ContextMenuImageType

public ContextMenuButtonImageType ContextMenuImageType

Gets or sets which picture is drawn as the context menu button: the built-in round button, your icon or your bitmap.

Value
One of the ContextMenuButtonImageType values. The default is ContextMenuButtonImageType.Default, the built-in button.
Remarks

Your own picture is used only while UseCustomImageForContextMenuButton is true.

See also

ContextMenuType

public ContextMenuType ContextMenuType

Gets or sets which of the two menu properties the context menu button opens.

Value
ContextMenuType.ContextMenuStrip opens HeaderContextMenuStrip; ContextMenuType.ContextMenu opens HeaderContextMenu. The default is ContextMenuType.ContextMenuStrip.
Remarks

The two properties let an application keep two menus ready and switch between them, for example a short menu and a full one.

ControlIsInExpandedState

public bool ControlIsInExpandedState

Gets or sets whether the control is expanded, as opposed to collapsed to its caption.

Value
true when expanded. The default is true.
Remarks

Reading the property tells you the current state, whether the user collapsed the control with the caption button or code called PerformCollapseExpand.

Setting it does not resize the control. It records the current height as the one an expand returns to, and redraws the collapse button for the new state. To collapse the control from code, call PerformCollapseExpand.

See also

CustomContextMenuButtonImageTransparencyColor

public Color CustomContextMenuButtonImageTransparencyColor

Gets or sets the colour in CustomImageForContextMenuButton that is made transparent, so that the caption shows through the picture's background.

Value
The default is Color.Transparent.
Remarks

The colour is applied to the bitmap itself, and only while UseCustomImageForContextMenuButton is true and a bitmap has been assigned. It has no effect on CustomIconForContextMenuButton.

CustomIconForContextMenuButton

public Icon CustomIconForContextMenuButton

Gets or sets the icon drawn as the context menu button when ContextMenuImageType is ContextMenuButtonImageType.Icon.

Value
The default is null.
Remarks

The icon is drawn 16 logical pixels square, and only while UseCustomImageForContextMenuButton is true.

See also

CustomImageForContextMenuButton

public Bitmap CustomImageForContextMenuButton

Gets or sets the picture drawn as the context menu button when ContextMenuImageType is ContextMenuButtonImageType.Bitmap.

Value
The default is null.
Remarks

The picture is drawn 16 logical pixels square, and only while UseCustomImageForContextMenuButton is true.

When that property is already true, the pixels of CustomContextMenuButtonImageTransparencyColor are made transparent in the bitmap you assign – the bitmap itself is changed – so set UseCustomImageForContextMenuButton and the transparency colour first.

See also

DisplayRectangle

public override Rectangle DisplayRectangle

Gets the area available to the hosted controls, in client coordinates.

Value
The client area: the control less its caption, footer, border and drop shadow band.
Remarks

The caption, footer, border and shadow are all outside the client area, so docked and anchored children stop short of them with no margins of your own.

DrawBorderAround

public DrawBorderAround DrawBorderAround

Gets or sets which bands – the caption, the footer, both or neither – have a border drawn just inside their edges.

Value
The default is DrawBorderAround.None.
Designer category
Header and footer rendering
Remarks

The caption's border is drawn with HeaderBorderColor and HeaderBorderThickness, the footer's with FooterBorderColor and FooterBorderThickness. A footer border shows only while the footer is drawn.

DrawFooter

public bool DrawFooter

Gets or sets whether a footer band is drawn along the edge opposite the caption.

Value
true to draw the footer. The default is false.
Designer category
Footer rendering
Remarks

The footer is part of the frame, so turning it on makes the client area smaller. No footer is drawn when HeaderLocation is HeaderLocation.Bottom.

FooterText ignores new text while this property is false, so turn the footer on first.

See also

DropShadowColor

public Color DropShadowColor

Gets or sets the colour of the drop shadow.

Value
The default is Color.Black. The colour's alpha component is ignored; DropShadowOpacity sets how strong the shadow is.
Designer category
Appearance
Remarks

Used only while ShouldDrawDropShadow is true.

DropShadowDepth

public int DropShadowDepth

Gets or sets how far the drop shadow reaches beyond the frame.

Value
The depth in logical pixels (1/96 inch), from 0 to 16. The default is 4. Negative values are stored as 0 and values above 16 as 16.
Default
DropShadowPainter.DefaultDepth
Designer category
Appearance
Remarks

The depth is scaled with the display. A depth of 0 draws no shadow and gives the band back to the client area. Used only while ShouldDrawDropShadow is true.

See also

DropShadowOpacity

public int DropShadowOpacity

Gets or sets how dark the drop shadow is where it is strongest, next to the frame.

Value
From 0 (invisible) to 255 (solid DropShadowColor). The default is 96. Values outside the range are clamped to it.
Default
DropShadowPainter.DefaultOpacity
Designer category
Appearance
Remarks

Used only while ShouldDrawDropShadow is true.

See also

EnableCollapseExpandButton

public bool EnableCollapseExpandButton

Gets or sets whether the caption shows a round button that collapses the control to its caption and expands it again.

Value
true to show the collapse button. The default is true.
Remarks

The collapse button and the context menu button share one place at the end of the caption, so setting this property also sets EnableHeaderContextMenu to the opposite value.

Clicking the button sets the control's height to the caption's height (plus the drop shadow, when one is drawn) and clicking it again restores the height it had. The control does not collapse in the designer. The button is drawn, and answers clicks, only when HeaderLocation is HeaderLocation.Top; its colours are ExpandCollapseCircleFillColor and ExpandCollapseUpDownArrowsFillColor.

See also

EnableHeaderContextMenu

public bool EnableHeaderContextMenu

Gets or sets whether the caption shows a round button that opens a menu of commands for the pane.

Value
true to show the context menu button. The default is false.
Designer category
Header rendering
Remarks

The context menu button and the collapse button share one place at the end of the caption, so setting this property also sets EnableCollapseExpandButton to the opposite value.

Clicking the button raises HeaderContextMenuAboutToBeDisplayed and then, unless a handler cancels it, opens the menu chosen by ContextMenuType at the point clicked. The caption text is shortened to leave room for the button.

Example
var contactsMenu = new ContextMenuStrip();
contactsMenu.Items.Add("New contact", null, (s, e) => CreateContact());
contactsMenu.Items.Add("Import from CSV...", null, (s, e) => ImportContacts());

contactsPane.EnableHeaderContextMenu = true;
contactsPane.HeaderContextMenuStrip = contactsMenu;
See also

EndColorForBackgroundRendering

public Color EndColorForBackgroundRendering

Gets or sets the colour the client area's background gradient ends with.

Value
The default comes from the ColorScheme: RGB(197, 221, 250) for the default ColorScheme.Blue scheme, white for the others.
Designer category
Color
See also

EndColorForFooterRendering

public Color EndColorForFooterRendering

Gets or sets the colour the footer band's gradient ends with.

Value
The default comes from the ColorScheme: RGB(197, 221, 250) for the default ColorScheme.Blue scheme, white for the others.
Designer category
Footer rendering
See also

EndColorForHeaderRendering

public Color EndColorForHeaderRendering

Gets or sets the colour the caption band's gradient ends with.

Value
The default comes from the ColorScheme: RGB(197, 221, 250) for the default ColorScheme.Blue scheme, white for the others.
Designer category
Header rendering
Remarks

Choosing a ColorScheme other than ColorScheme.None overwrites this colour.

See also

ExpandCollapseCircleFillColor

public Color ExpandCollapseCircleFillColor

Gets or sets the colour of the round body of the collapse button.

Value
The default is SystemColors.Window.
Remarks

ColorScheme does not change this colour.

See also

ExpandCollapseUpDownArrowsFillColor

public Color ExpandCollapseUpDownArrowsFillColor

Gets or sets the colour of the double arrow on the collapse button, which points up while the control is expanded and down while it is collapsed.

Value
The default is SystemColors.WindowText.
Remarks

ColorScheme does not change this colour.

See also

FooterBorderColor

public Color FooterBorderColor

Gets or sets the colour of the border drawn inside the footer band.

Value
The default is Color.White.
Designer category
Footer rendering
Remarks

Used only while DrawBorderAround includes the footer.

See also

FooterBorderThickness

public float FooterBorderThickness

Gets or sets the thickness of the border drawn inside the footer band.

Value
The thickness in pixels. The default is 2.
Designer category
Footer rendering
Remarks

Used only while DrawBorderAround includes the footer.

See also

FooterCaptionFont

public Font FooterCaptionFont

Gets or sets the font of the footer text.

Value
The default is the control's Control.Font, which the footer keeps following until this property is set. Setting null makes it follow the control's font again.
Designer category
Footer rendering
Remarks

The footer is made deep enough for one line of this font whatever FooterCaptionHeight says.

See also

FooterCaptionHeight

public int FooterCaptionHeight

Gets or sets the depth of the footer band – its height along the bottom or top, its width down the left or right.

Value
The depth in logical pixels (1/96 inch). The default is 20.
Designer category
Footer rendering
Remarks

The value is scaled with the display, and the band is never drawn shallower than one line of FooterCaptionFont plus a small margin. The client area is re-measured for a new depth the next time the control is resized.

See also

FooterGradientDrawingDirection

public LinearGradientMode FooterGradientDrawingDirection

Gets or sets the direction in which the footer band's gradient runs.

Value
The default is Vertical.
Designer category
Footer rendering
Remarks

As with the caption, the direction is taken as if the band lay along the top or bottom, and it is not used in the HeaderFooterDrawingStyle.OfficeStyle drawing style.

See also

FooterText

public string FooterText

Gets or sets the text shown in the footer band – a status line such as a count of items.

Value
The default is "Footer text!".
Designer category
Footer rendering
Remarks

New text is ignored while DrawFooter is false: turn the footer on before setting its text.

The text is drawn on one line in FooterCaptionFont and FooterTextForeColor, laid out by FooterTextStringFormat.

Example
tasksPane.DrawFooter = true;
tasksPane.FooterText = $"{openTasks.Count} open, {overdueTasks.Count} overdue";
See also

FooterTextForeColor

public Color FooterTextForeColor

Gets or sets the colour of the footer text.

Value
The default is SystemColors.ActiveCaption.
Designer category
Footer rendering
See also

FooterTextStringFormat

public StringFormat FooterTextStringFormat

Gets or sets how the footer text is aligned, wrapped and trimmed.

Value
The default centres the text both ways, keeps it on one line and trims it with an ellipsis.
Designer category
Footer rendering
Remarks

This property is not shown in the Properties window and is not saved by the designer; set it in code.

See also

HeaderBitmapTransparencyColor

public Color HeaderBitmapTransparencyColor

Gets or sets the colour in HeaderImage that is made transparent, so that the caption's gradient shows through the picture's background.

Value
The default is Color.Transparent.
Designer category
Header rendering
Remarks

The colour is applied to the bitmap itself, when it is assigned and again when this colour changes, so set the colour first. Pixels made transparent stay transparent.

See also

HeaderBorderColor

public Color HeaderBorderColor

Gets or sets the colour of the border drawn inside the caption band.

Value
The default is Color.White.
Designer category
Header rendering
Remarks

Used only while DrawBorderAround includes the caption. A light colour on a darker gradient gives the band a raised look.

See also

HeaderBorderThickness

public float HeaderBorderThickness

Gets or sets the thickness of the border drawn inside the caption band.

Value
The thickness in pixels. The default is 2.
Designer category
Header rendering
Remarks

Used only while DrawBorderAround includes the caption.

See also

HeaderCaptionFont

public Font HeaderCaptionFont

Gets or sets the font of the caption text.

Value
The default is the control's Control.Font, which the caption keeps following until this property is set. Setting null makes it follow the control's font again.
Designer category
Header rendering
Remarks

The caption band is made deep enough for one line of this font whatever HeaderCaptionHeight says.

See also

HeaderCaptionHeight

public int HeaderCaptionHeight

Gets or sets the depth of the caption band – its height when it runs along the top or bottom, its width when it runs down the left or right.

Value
The depth in logical pixels (1/96 inch). The default is the system's window caption height, CaptionHeight. Values below 20 are raised to 20.
Designer category
Header rendering
Remarks

The value is scaled with the display, and the band is never drawn shallower than one line of HeaderCaptionFont plus a small margin, so a large caption font makes the band deeper whatever this property says.

The caption is part of the frame: a deeper caption makes the client area smaller and moves the docked children.

See also

HeaderContextMenu

public ContextMenu HeaderContextMenu

Gets or sets the menu the context menu button opens when ContextMenuType is ContextMenuType.ContextMenu.

Value
The default is null: no menu.
Designer category
Header rendering
Remarks

With the default ContextMenuType, the button opens HeaderContextMenuStrip instead; most applications need only that one.

See also

HeaderContextMenu

public ContextMenuStrip HeaderContextMenu

Gets or sets the menu the context menu button opens when ContextMenuType is ContextMenuType.ContextMenu.

Value
The default is null: no menu.
Designer category
Header rendering
Remarks

With the default ContextMenuType, the button opens HeaderContextMenuStrip instead; most applications need only that one.

See also

HeaderContextMenuStrip

public ContextMenuStrip HeaderContextMenuStrip

Gets or sets the menu the context menu button opens.

Value
The default is null: no menu.
Designer category
Header rendering
Remarks

The menu is used while ContextMenuType is ContextMenuType.ContextMenuStrip, the default, and the button shows only while EnableHeaderContextMenu is true.

See also

HeaderFooterDrawingStyle

public HeaderFooterDrawingStyle HeaderFooterDrawingStyle

Gets or sets how the caption and footer bands are filled: a plain gradient, or an Office-style two-tone band.

Value
The default is HeaderFooterDrawingStyle.Default.
Remarks

Both styles use the bands' start and end colours; the Office style blends them into a lighter upper half and a deeper lower half and ignores the gradient directions.

See also

HeaderGradientDrawingDirection

public LinearGradientMode HeaderGradientDrawingDirection

Gets or sets the direction in which the caption band's gradient runs.

Value
The default is Vertical: from the start colour at the band's top edge to the end colour at its bottom edge.
Designer category
Header rendering
Remarks

A band down the left or right is drawn as if it lay along the top and is then turned on its side, gradient and all, so that its top edge faces outwards. The direction is not used in the HeaderFooterDrawingStyle.OfficeStyle drawing style.

See also

HeaderIcon

public Icon HeaderIcon

Gets or sets the icon drawn at the start of the caption, before the text.

Value
The default is null: no icon.
Designer category
Header rendering
Remarks

Setting this property also sets HeaderImageType to HeaderImageType.Icon. The icon is drawn at its own size, reduced to the caption's depth when it is larger, and the text starts after it.

See also

HeaderImage

public Bitmap HeaderImage

Gets or sets the picture drawn at the start of the caption, before the text, when an icon will not do.

Value
The default is null: no picture.
Designer category
Header rendering
Remarks

Setting this property also sets HeaderImageType to HeaderImageType.Bitmap. The picture is drawn at its own size, reduced to the caption's depth when it is larger.

The bitmap you assign is changed in place: the pixels of HeaderBitmapTransparencyColor are made transparent in it. Assign a copy if the original is used elsewhere. The caption is not redrawn by this setter; it shows the picture at its next repaint.

Example
var picture = new Bitmap("Images\\calendar-16.bmp");
calendarPane.HeaderBitmapTransparencyColor = Color.Magenta;   // the bitmap's background colour
calendarPane.HeaderImage = picture;
calendarPane.HeaderText = "Calendar";
See also

HeaderImageType

public HeaderImageType HeaderImageType

Gets or sets which picture, if any, is drawn at the start of the caption.

Value
The default is HeaderImageType.Icon.
Designer category
Header rendering
Remarks

Setting HeaderIcon or HeaderImage sets this property to match, so set it yourself only to switch between the two, or to HeaderImageType.None to hide the picture without discarding it. Nothing is drawn when the chosen picture is null.

HeaderLocation

public HeaderLocation HeaderLocation

Gets or sets which edge of the control the caption band runs along.

Value
The default is HeaderLocation.Top.
Designer category
Header rendering
Remarks

The footer, when DrawFooter is on, runs along the opposite edge. On the left and right the caption and the footer are drawn turned on their side.

With HeaderLocation.Bottom no footer is drawn, and the collapse button is drawn only with HeaderLocation.Top.

HeaderText

public String HeaderText

Gets or sets the title shown in the caption band.

Value
The default is "Header text!".
Designer category
Header rendering
Remarks

The text is drawn on one line in HeaderCaptionFont and HeaderTextForeColor, centred by default and trimmed with an ellipsis when it is too long (see HeaderTextStringFormat). Room is left for the icon and for the context menu button.

Use an empty string for a caption with no title; null stops the caption from being drawn properly.

See also

HeaderTextForeColor

public Color HeaderTextForeColor

Gets or sets the colour of the caption text.

Value
The default is SystemColors.ActiveCaption.
Designer category
Header rendering
Remarks

ColorScheme does not change this colour, so pick one that reads well on the scheme's caption gradient.

See also

HeaderTextStringFormat

public StringFormat HeaderTextStringFormat

Gets or sets how the caption text is aligned, wrapped and trimmed.

Value
The default centres the text both ways, keeps it on one line and trims it with an ellipsis (EllipsisCharacter).
Remarks

This property is not shown in the Properties window and is not saved by the designer; set it in code. You can also change the existing object, for example its StringFormat.Alignment, and then call Control.Refresh.

Example
// Left-align the caption, Outlook style.
ordersPane.HeaderTextStringFormat.Alignment = StringAlignment.Near;
ordersPane.Refresh();
See also

ShouldDrawDropShadow

public bool ShouldDrawDropShadow

Gets or sets whether a soft shadow is drawn along the control's bottom and right edges, lifting the pane off the form.

Value
true to draw the shadow. The default is false.
Default
false
Designer category
Appearance
Remarks

A control cannot paint outside its own bounds, so the shadow is drawn inside them: a band DropShadowDepth deep along the bottom and right is given to the shadow, and the frame, caption and client area shrink by that much. Turning the shadow on therefore moves anything docked or anchored to those edges. The part of the band the shadow does not cover is painted in the nearest opaque parent's Control.BackColor.

Example
notesPane.ShouldDrawDropShadow = true;
notesPane.DropShadowDepth = 6;
notesPane.DropShadowOpacity = 120;
notesPane.DropShadowColor = Color.FromArgb(40, 40, 60);
See also

Size

public new Size Size

Gets or sets the size of the control, including its caption, footer, border and drop shadow.

Value
The size in pixels, as for Size.
Remarks

The first size assigned through this property while the control is expanded is recorded as the height an expand returns to. Assigning it through a Control reference sets the size without recording it.

StartColorForBackgroundRendering

public Color StartColorForBackgroundRendering

Gets or sets the colour the client area's background gradient starts with – the area behind the hosted controls.

Value
The default comes from the ColorScheme: RGB(128, 167, 225) for the default ColorScheme.Blue scheme.
Designer category
Color
Remarks

The gradient runs to EndColorForBackgroundRendering in the direction BackgroundGradientDrawingDirection gives. The control paints this gradient instead of Control.BackColor. Choosing a ColorScheme other than ColorScheme.None overwrites the colour.

See also

StartColorForFooterRendering

public Color StartColorForFooterRendering

Gets or sets the colour the footer band's gradient starts with.

Value
The default comes from the ColorScheme: RGB(128, 167, 225) for the default ColorScheme.Blue scheme.
Designer category
Footer rendering
Remarks

The gradient runs to EndColorForFooterRendering in the direction FooterGradientDrawingDirection gives. Choosing a ColorScheme other than ColorScheme.None overwrites the colour.

See also

StartColorForHeaderRendering

public Color StartColorForHeaderRendering

Gets or sets the colour the caption band's gradient starts with.

Value
The default comes from the ColorScheme: RGB(128, 167, 225) for the default ColorScheme.Blue scheme.
Designer category
Header rendering
Remarks

The gradient runs from this colour to EndColorForHeaderRendering in the direction HeaderGradientDrawingDirection gives. In the HeaderFooterDrawingStyle.OfficeStyle drawing style both colours are blended into a two-tone band instead, and this colour also outlines it.

While ColorScheme is anything other than ColorScheme.None, setting this colour also sets BorderColor to it, and choosing a scheme later overwrites it.

See also

UseAntiAliasingAsHeaderCaptionTextRenderingHint

public bool UseAntiAliasingAsHeaderCaptionTextRenderingHint

Gets or sets whether the caption text is drawn with plain anti-aliasing rather than grid-fitted anti-aliasing.

Value
true for AntiAlias; false for AntiAliasGridFit. The default is false.
Designer category
Header and Footer rendering
Remarks

Plain anti-aliasing gives softer, slightly wider text that some prefer for large or bold caption fonts. The setting applies to the caption only; the footer text uses the system's default rendering.

UseCustomImageForContextMenuButton

public bool UseCustomImageForContextMenuButton

Gets or sets whether the context menu button is drawn with a picture of your own instead of the built-in round button.

Value
true to draw the picture. The default is false.
Remarks

The picture is CustomIconForContextMenuButton or CustomImageForContextMenuButton, as ContextMenuImageType chooses, drawn 16 logical pixels square. The built-in button is drawn while this property is false, while ContextMenuImageType is ContextMenuButtonImageType.Default, or while both pictures are null.

Example
filtersPane.EnableHeaderContextMenu = true;
filtersPane.UseCustomImageForContextMenuButton = true;
filtersPane.ContextMenuImageType = ContextMenuButtonImageType.Icon;
filtersPane.CustomIconForContextMenuButton = new Icon("Images\\filter.ico");
See also

Methods

OnFontChanged

protected override void OnFontChanged(EventArgs e)

Raises the Control.FontChanged event, and passes the new font on to any caption font that has not been set explicitly.

Parameters
e
The data for the event.
Remarks

The caption and footer fonts follow Control.Font – whether it is set in code, in the designer or inherited from the parent – until HeaderCaptionFont or FooterCaptionFont is set. Set either to null to make it follow the control's font again. The bands grow when needed to fit one line of the new font.

An override should call the base method so that the caption keeps following the font.

OnPaint

protected override void OnPaint(PaintEventArgs e)

Paints the client area's background gradient, raises the Control.Paint event, and redraws the caption, footer and border.

Parameters
e
The data for the event.
Remarks

The background runs from StartColorForBackgroundRendering to EndColorForBackgroundRendering. A Control.Paint handler draws on top of it. Nothing is painted while the control has no width or height.

OnPaintBackground

protected override void OnPaintBackground(PaintEventArgs pevent)

Does nothing: the whole client area is painted in OnPaint, which avoids flicker.

Parameters
pevent
The data for the event; not used.

OnResize

protected override void OnResize(EventArgs e)

Raises the Control.Resize event after redrawing the caption, footer and border for the new size.

Parameters
e
The data for the event.
Remarks

An override should call the base method, or the bands are not redrawn when the control is resized.

PerformCollapseExpand

public void PerformCollapseExpand(bool collapse)

Collapses the control to its caption, as clicking the collapse button does.

Parameters
collapse
true to collapse the control; false to expand it to the height it had before it collapsed.
Remarks

Collapsing records the current height and sets the height to the caption's depth (plus the drop shadow, when one is drawn). Expanding – from code or by a click on the collapse button – restores the recorded height. Asking for the state the control is already in changes nothing.

The method works whether or not EnableCollapseExpandButton is on, and also in the designer. Collapsing suits a caption along the top: the control always shrinks upwards from the bottom edge.

Example
// Keep the search pane folded away until it is needed.
searchPane.PerformCollapseExpand(true);

// ... later, open it again at the height it had.
searchPane.PerformCollapseExpand(false);
See also

WndProc

protected override void WndProc(ref Message theWindowMessage)

Processes the window messages that size, paint and hit test the caption and footer, and turns clicks on them into HeaderClicked, FooterClicked, a collapse or the context menu.

Parameters
theWindowMessage
The window message to process.
Remarks

An override must call the base method for every message, or the caption, the footer and their clicks stop working.

Events

FooterClicked

public event EventHandler FooterClicked

Occurs when the footer band is clicked.

Remarks

The event is raised when the left mouse button is released over the footer. A footer is drawn only while DrawFooter is true and HeaderLocation is not HeaderLocation.Bottom.

See also

HeaderClicked

public event EventHandler HeaderClicked

Occurs when the caption band is clicked.

Remarks

The event is raised when the left mouse button is released over the caption, anywhere except on its collapse or context menu button: a click on that button collapses the control or opens the menu instead.

Example
tasksPane.HeaderClicked += (sender, e) => tasksPane.PerformCollapseExpand(true);
See also

HeaderContextMenuAboutToBeDisplayed

public event HeaderContextMenuAboutToBeDisplayedHandler HeaderContextMenuAboutToBeDisplayed

Occurs when the context menu button in the caption is clicked, just before the menu opens.

Remarks

Set the handler's cancel argument to true to keep the menu closed. The event is raised whenever EnableHeaderContextMenu is on and the button is clicked, even when no menu has been assigned.

The menu opens at the point that was clicked. Which menu opens depends on ContextMenuType.

See also