BinaryPowerTabStrip
A tab control that draws its own headers in one of six styles, shows one page per tab, and copes with more tabs than will fit – by wrapping them onto extra rows or by listing the rest in a drop-down menu.
public partial class BinaryPowerTabStrip : ContainerControl
Inherits from / implements: ContainerControl
Remarks
Use it where a window holds several documents, records or views and the user moves between them: open files in an editor, customer accounts in a CRM screen, reports in a dashboard.
Pages and selection
Each tab is a BinaryPowerTabPage, a panel holding the tab's controls and carrying its
header text, image, tooltip and colours. Add pages with AddTab() or through
TabPages (not Controls). The selected page (SelectedTabPage) is
docked under the headers and the others are hidden, so nothing is re-parented when the selection changes.
TabPageSelectionChanged reports selection changes, and also pages being added, removed or
changed.
Closing and reordering
Each header draws a close button (EnableTabPageLevelCloseButtonRendering). A click raises
TabPageClosing, which can cancel, then removes the page and raises TabPageClosed.
With EnableDragAndDropOfTabPages on, users drag headers into a new order.
More tabs than fit
TabsOverflowMode chooses: OverflowMode.Menu (the default) keeps one row and
adds a drop-down glyph listing every tab; OverflowMode.MultiLine wraps the headers onto as many
rows as they need.
Appearance
TabRenderingStyle picks the header shape and colouring, from the Visual Studio 2008 look
(the default) to RenderingStyle.Custom, whose gradients come from CustomStartColor
and CustomEndColor or each page's own colours. Headers run along the top or the bottom
(TabPagesRenderingLocation) and can cast drop shadows
(ShouldDrawTabHeaderDropShadow). Sizes are in logical pixels (1/96 inch), scaled to the
display.
Examples
A form showing open documents as tabs. Closing a tab with unsaved changes asks first, and the form's title follows the selected tab.
// In a form's constructor (using System.Windows.Forms and Binarymission.WinForms.Controls.TabControls).
var documents = new BinaryPowerTabStrip { Dock = DockStyle.Fill, TabPageHeaderWidth = 160, EnableDragAndDropOfTabPages = true };
foreach (string file in new[] { "Q3 forecast.xlsx", "Board minutes.docx", "Supplier contract.pdf" })
{
var page = new BinaryPowerTabPage { Text = file, ToolTipText = "Finance share: " + file };
var editor = new RichTextBox { Dock = DockStyle.Fill };
editor.TextChanged += (sender, e) => page.TabPageContentIsDirty = true;
page.Controls.Add(editor);
documents.AddTab(page);
}
documents.TabPageSelectionChanged += e =>
{
if (e.TabPageChangeType == TabPageChangeTriggerSource.SelectionChanged && e.TabPage != null)
Text = e.TabPage.Text + " - Open documents";
};
documents.TabPageClosing += e =>
{
e.Cancel = e.TabPage.TabPageContentIsDirty
&& MessageBox.Show(this, "Discard the changes to " + e.TabPage.Text + "?", "Close document",
MessageBoxButtons.YesNo) == DialogResult.No;
};
Controls.Add(documents);See also
Members at a glance
| Constructors | |
|---|---|
BinaryPowerTabStrip | Creates an empty tab strip, 300 by 250 pixels, in the Visual Studio 2008 style with menu overflow. |
| Properties | |
BorderStyle | Gets the border style, which is always BorderStyle.None; the strip draws
its own border (DrawBorderAroundTabStrip). |
Controls | Gets the controls inside the strip, which are its pages. Use TabPages to add and remove tabs. |
CustomEndColor | Gets or sets the colour the header fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles. |
CustomStartColor | Gets or sets the colour the header fill starts from in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles. |
DragDropIndicatorColor | Gets or sets the colour of the bar that shows where a dragged header will land. |
DrawBorderAroundTabStrip | Gets or sets whether a one-pixel border is drawn round the whole strip. |
DrawTabPageOnTopOfEachOther | Gets or sets whether neighbouring headers overlap, each slanting over the one before it, with the selected header on top. |
DropShadowColor | Gets or sets the colour of the strip's drop shadow. |
DropShadowDepth | Gets or sets how far the strip's drop shadow reaches, which is also the width of the band it takes from the strip. |
DropShadowOpacity | Gets or sets how dark the strip's drop shadow is at its strongest. |
EmptySpaceLengthBeforeTheFirstTabPage | Gets or sets the space left before the first header of each row. |
EnableAutomaticUpdateOfTabPagesHeaderSize | Gets or sets whether the header height is recalculated to fit the tallest caption or image whenever the strip's font or a page's image changes. |
EnableControlledLayoutRendering | Gets or sets a layout option that the strip stores but does not act on. |
EnableDragAndDropOfTabPages | Gets or sets whether users can drag a tab header to a new position. |
EnableTabPageLevelCloseButtonRendering | Gets or sets whether each tab header draws its own close button. |
ExtendedWindowsXPRenderingFirstColor | Gets or sets the colour of the thin outer line along the selected header's leading edge in the
RenderingStyle.ExtendedWindowsXP style. |
ExtendedWindowsXPRenderingSecondColor | Gets or sets the colour of the two-pixel inner line along the selected header's leading edge in the
RenderingStyle.ExtendedWindowsXP style. |
GapBetweenTabPages | Gets or sets the space between two neighbouring headers, while
TabPagesHaveGapBetweenThem is on. |
HeaderFont | Gets or sets the font of the header text, and gives it to every page. |
HeaderTextCloseButtonExtraGap | Gets or sets the extra width added to every header when the headers are auto-sized. |
IsBackgroundTransparent | Gets or sets whether the strip's background, and its pages', is transparent. |
KeepShowingTooltipEvenWhenMousePointerIsMoving | Gets or sets whether the tooltip follows the pointer from header to header, rather than appearing only when the pointer rests. |
NewlyAddedPagesAreLocatedAtLeftCorner | Gets or sets a placement preference for new pages that the strip stores but does not use to place them. |
OverflowMenuGlyphDrawnInEnlargedMode | Gets or sets whether the overflow glyph is drawn at OverflowMenuGlyphSize, or by your
PowerTabStripElementsRenderer, rather than as the standard 16-pixel arrow. |
OverflowMenuGlyphSize | Gets or sets the size of the overflow glyph's box while
OverflowMenuGlyphDrawnInEnlargedMode is on. |
OverflowMenuLabelFont | Gets or sets the font of the overflow menu's title. |
OverflowMenuLabelForeColor | Gets or sets the colour of the overflow menu's title. |
OverflowMenuLabelMargin | Gets or sets the space round the overflow menu's title. |
OverflowMenuLabelText | Gets or sets the title shown at the top of the overflow menu, while
OverflowMenuShouldRenderTitleLabel is on. |
OverflowMenuShouldRenderTitleLabel | Gets or sets whether the overflow menu starts with a title above the list of tabs. |
PagesCurrentlyDisplayedInActiveTabControlView | Gets the tab headers drawn by the last paint, in the order they were drawn. |
PowerTabStripElementsRenderer | Gets or sets an object of your own that draws the overflow glyph, in place of the built-in drop-down arrow. |
PreventInvalidation | Gets or sets whether changing a page's BinaryPowerTabPage.Text leaves the strip unpainted until
this is turned off again. |
RenderFullTextForTabPageHeader | Gets or sets how a caption wider than TabPageHeaderWidth is shortened: in the middle,
keeping its start and end, or at the end. |
ReserveCloseButtonSpaceOnAllTabPages | Gets or sets whether room for a close button is added to every header, or only to the headers that draw one. |
SelectedPageHeaderTextIsRenderedBold | Gets or sets whether the selected tab's header text is drawn in bold when
SelectedTabPageHeaderFont is not set. |
SelectedTabPage | Gets or sets the tab whose page is on show. |
SelectedTabPageHeaderFont | Gets or sets the font of the selected tab's header text. |
ShouldAutoSizeTabs | Gets or sets whether every header is given the same width – that of the widest. |
ShouldDrawDropShadow | Gets or sets whether the strip casts a drop shadow along its bottom and right-hand edges. |
ShouldDrawTabHeaderDropShadow | Gets or sets whether each tab header casts a soft drop shadow down and to the right, the selected header's falling over its neighbours. |
ShouldDrawTabPageHeaderInMultiLines | Gets or sets whether a header's text may run onto more than one line. |
ShouldEnableControlDiagnosticsReporting | Gets or sets whether the strip writes a report of the headers on show to
Trace when the pointer enters or leaves it. |
ShouldReportCurrentlyDisplayedTabPagesList | Gets or sets whether each paint records the headers it drew in
PagesCurrentlyDisplayedInActiveTabControlView. |
ShouldRespectTabPageSetupOrderUponSelectedPageChange | Gets or sets whether selecting a tab whose header is out of view keeps the tabs in their order. |
ShouldUpdateUponParentMove | Gets or sets whether the selected page is repainted at once whenever the form the strip is on is moved. |
ShouldUpdateUponParentResize | Gets or sets whether the selected page is repainted at once whenever the form the strip is on is resized. |
ShowCloseWindowButton | Gets or sets whether the strip-level close button, at the right-hand end of the headers, closes the selected tab when clicked. |
ShowDragDropIndicator | Gets or sets whether a header being dragged shows where it will land: a bar between two headers, with a caret
at each end, in DragDropIndicatorColor. |
ShowOverflowMenuGlyph | Gets or sets whether the overflow glyph – the drop-down that lists the tabs – is shown at the right-hand end of the headers. |
ShowToolTip | Gets or sets whether a page's BinaryPowerTabPage.ToolTipText is shown when the pointer
rests on its header. |
Size | Gets or sets the size of the strip, and lays the headers out again for the new size. |
TabBottomOrientationCloseButtonPosition | Gets or sets whether a header's close button sits near its top or its bottom edge when the tabs run along the bottom of the strip. |
TabHeaderDropShadowColor | Gets or sets the colour of the tab headers' drop shadows. |
TabHeaderDropShadowDepth | Gets or sets how far each tab header's drop shadow reaches. |
TabHeaderDropShadowOpacity | Gets or sets how dark the tab headers' drop shadows are at their strongest. |
TabHeaderStringFormat | Gets or sets the text layout used to measure and draw the header captions. |
TabPageBorderColor | Gets or sets the colour of the headers' outline and of the border round the strip. |
TabPageCloseButtonMouseEnterColor | Gets or sets the colour a header's close-button cross turns while the pointer is over it. |
TabPageCloseButtonRectangleBorderColor | Gets or sets the outline of the box drawn behind the strip-level close button while the pointer is over it. |
TabPageCloseButtonRectangleFillColor | Gets or sets the fill of the box drawn behind the strip-level close button while the pointer is over it. |
TabPageCurrentSelectionIndicatorEndColor | Gets or sets the colour the selected header's fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles. |
TabPageCurrentSelectionIndicatorStartColor | Gets or sets the colour the selected header's fill starts from in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles. |
TabPageHeaderDrawingGradientOrientation | Gets or sets the direction of the header fill's gradient in the RenderingStyle.Custom
and RenderingStyle.TrapeziumTop styles. |
TabPageHeaderForeColor | Gets or sets the colour of the header text. |
TabPageHeaderHeight | Gets or sets the height of a row of tab headers. |
TabPageHeaderHorizontalPadding | Gets or sets the room added to each header's width on top of its text – the space that frames the caption. |
TabPageHeaderShowsSideBar | Gets or sets whether each header carries a coloured bar along its right-hand edge in the
RenderingStyle.Custom style. |
TabPageHeaderTextFontOverridesControlDefault | Gets or sets whether the selected tab's header text is drawn in its page's own
BinaryPowerTabPage.HeaderTextFont, like the other headers, rather than in the
selected-tab font. |
TabPageHeaderWidth | Gets or sets the widest a header's text may be; longer captions are shortened with an ellipsis. |
TabPageSideBarFillColor | Gets or sets the colour of the side bar on each header, when TabPageHeaderShowsSideBar
is on. |
TabPages | Gets the strip's pages, in tab order. |
TabPagesCloseButtonColor | Gets or sets the colour of the cross on the close buttons. |
TabPagesHaveGapBetweenThem | Gets or sets whether the headers are spaced apart by GapBetweenTabPages rather than
drawn edge to edge. |
TabPagesOverFlowMenuBackColor | Gets or sets the background of the overflow menu, including its image margin. |
TabPagesOverFlowMenuBorderColor | Gets or sets the colour of the overflow menu's border and separators. |
TabPagesOverFlowMenuDropDownColor | Gets or sets the colour of the overflow glyph – the bar and arrow the menu drops from – rather than of the menu itself. |
TabPagesOverFlowMenuFont | Gets or sets the font of the overflow menu. |
TabPagesOverFlowMenuForeColor | Gets or sets the colour of the overflow menu's text. |
TabPagesOverFlowMenuGlyphActiveRectangleBorderColor | Gets or sets the outline of the box drawn behind the overflow glyph while the pointer is over it. |
TabPagesOverFlowMenuGlyphActiveRectangleFillColor | Gets or sets the fill of the box drawn behind the overflow glyph while the pointer is over it. |
TabPagesOverFlowMenuHighlightColor | Gets or sets the colour drawn behind, and round, the item the pointer is over in the overflow menu. |
TabPagesOverFlowMenuHighlightTextColor | Gets or sets a text colour for the overflow menu's highlighted item, which the menu does not use. |
TabPagesOverFlowMenuShowImageMargin | Gets or sets whether the overflow menu keeps the strip down its left-hand side where item images go. |
TabPagesOverflowCalculationStrategy | Gets or sets how many auto-sized tabs the strip assumes fit on a row when it fills rows by counting tabs rather than measuring them. |
TabPagesRenderingLocation | Gets or sets whether the tab headers run along the top or the bottom of the strip. |
TabRenderingStyle | Gets or sets the shape and colouring of the tab headers. |
TabsOverflowMode | Gets or sets what the strip does when the headers are wider than it is: keep one row and list the tabs in a drop-down menu, or wrap them onto extra rows. |
ThemeBorderColorCanBeOverridden | Gets or sets whether border colours you set are kept in the styles that otherwise set their own. |
ToolTipConfiguration | Gets or sets how the tab headers' tooltips look and behave: their delays, colours, icon, title and style. |
UseLegacyMultiLineRowPacking | Gets or sets whether the rows of headers in OverflowMode.MultiLine mode are filled by
counting tabs rather than by measuring them. |
UseTabCurrentSelectionIndicatorColor | Gets or sets whether the selected header is filled with the selection colours in the
RenderingStyle.Custom and RenderingStyle.TrapeziumTop styles. |
| Methods | |
AddTab | Adds a page as the last tab, without selecting it. |
AddTab | Adds a page as the last tab, and selects it if asked to. |
AddTab | Adds a page as the first or the last tab, and selects it if asked to. |
Dispose | Releases the strip's resources, disposing every page it holds, the overflow menu and the tooltip. |
GetDisabledImageFromNormal | Makes a grey copy of an image, as a disabled header draws its page's image when it has no
BinaryPowerTabPage.DisabledImage. |
GetTabPageByPoint | Gets the tab whose header is at a point. |
HitTest | Tells which part of the strip is at a point: a header, a header's close button, the overflow glyph, the strip-level close button, or none of them. |
OnCreateControl | Starts watching the form and containers around the strip, for a strip added to a form that already exists, then carries on as the base class does. |
OnDoubleClick | Raises TabPageDoubleClicked for a double-click on a header, and the
Control.DoubleClick event for a double-click anywhere else. |
OnFontChanged | Raises the Control.FontChanged event, and recalculates the header height when
EnableAutomaticUpdateOfTabPagesHeaderSize is on. |
OnHandleCreated | Raises the Control.HandleCreated event, and starts watching the form and containers around the
strip so the headers are laid out again when they resize. |
OnHandleDestroyed | Stops watching the form and containers around the strip, then raises the Control.HandleDestroyed
event. |
OnKeyDown | Selects the next tab when Ctrl+Tab reaches the strip, then raises the Control.KeyDown
event. |
OnLayout | Raises the Control.Layout event, and at run time works out again how many headers fit. |
OnMouseCaptureChanged | Raises the Control.MouseCaptureChanged event, and abandons a header drag whose capture
was taken away while the button is still down – by a window activated from the keyboard, or a dialog
- so nothing is dropped later and no bar is left behind. |
OnMouseDown | Raises the Control.MouseDown event, then acts on a left-button press: selects the tab
under the pointer, opens the overflow menu, or closes a tab whose close button was pressed. |
OnMouseEnter | Raises the Control.MouseEnter event, and notes the header the pointer entered over,
for its tooltip. |
OnMouseHover | Raises the Control.MouseHover event, and shows the tooltip of the header under the
pointer. |
OnMouseLeave | Raises the Control.MouseLeave event, hides any tooltip and clears the highlights on
the buttons. |
OnMouseMove | Raises the Control.MouseMove event, then carries a header drag along, or updates the
tooltips and the highlights on the close buttons and the overflow glyph. |
OnMouseUp | Raises the Control.MouseUp event, and drops a header being dragged at the place the
drop bar shows. |
OnPaint | Paints the headers, the overflow glyph and any drop bar; the Control.Paint event is not
raised. |
OnParentBackColorChanged | Raises the Control.ParentBackColorChanged event, and repaints the drop-shadow band,
which shows the colour behind the strip. |
OnParentChanged | Raises the Control.ParentChanged event, and starts watching the strip's new form and
containers when it is moved to another parent at run time. |
OnResize | Raises the Control.Resize event, and resizes the page area to the room the headers
leave. |
OnSizeChanged | Raises the Control.SizeChanged event, then works out again how many headers fit and
lays them out for the new size. |
OnSystemColorsChanged | Raises the Control.SystemColorsChanged event and repaints the strip, whose default colours come
from the system palette. |
OnTabStyleRenderingStyleChanged | Raises the TabStyleRenderingStyleChanged event. |
RearrangeTabPageLocation | Moves a page to a new position among the tabs. |
RefreshLayout | Lays the headers and the page area out again from scratch. |
RemoveTab | Removes a page from the strip and selects a neighbouring tab. |
ResetExternal | Does nothing. Calling it has no effect on the strip. |
ResetInvalidate | Works out again how many headers fit, lays the strip out and repaints it. |
SetBoundsCore | Sets the strip's bounds with layout suspended on the strip and every control inside it, so the pages are laid out once for the new size. |
ShouldSerializeFont | Tells the designer whether to write Control.Font into the designer file: only when it differs
from the system's default font. |
ShouldSerializeItems | Part of the designer's serialisation support; not for use from application code. Returns
true when the strip has pages. |
ShouldSerializeSelectedItem | Part of the designer's serialisation support; not for use from application code. Always returns
true. |
WndProc | Processes the strip's window messages, reserving and painting the drop-shadow band when
ShouldDrawDropShadow is on. |
| Events | |
TabElementsLayoutChanging | Occurs just before the strip lays its headers out again. |
TabPageClosed | Occurs after the user has closed a tab with a close button and its page has been removed. |
TabPageClosing | Occurs when the user clicks a close button, before the page is removed; a handler can cancel. |
TabPageDoubleClicked | Occurs when the user double-clicks a tab header. |
TabPageSelectionChanged | Occurs when the selected tab changes, and also when a page is added, removed or changed. |
TabStyleRenderingStyleChanged | Occurs when OnTabStyleRenderingStyleChanged is called. |
Constructors
BinaryPowerTabStrip
Creates an empty tab strip, 300 by 250 pixels, in the Visual Studio 2008 style with menu overflow.
Remarks
The first page is selected when the strip first paints, unless one has been selected by then.
Properties
BorderStyle
Gets the border style, which is always BorderStyle.None; the strip draws
its own border (DrawBorderAroundTabStrip).
Controls
Gets the controls inside the strip, which are its pages. Use TabPages to add and remove tabs.
CustomEndColor
Gets or sets the colour the header fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Color.White.
Remarks
A page's own BinaryPowerTabPage.CustomEndColor, when set, takes precedence
for that page.
See also
CustomStartColor
Gets or sets the colour the header fill starts from in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles.
- Value
- The default is a light orange, RGB (255, 192, 128).
Remarks
The fill runs to CustomEndColor in the direction of
TabPageHeaderDrawingGradientOrientation. A page's own
BinaryPowerTabPage.CustomStartColor, when set, takes precedence for that page. The
selected header uses the selection colours instead while
UseTabCurrentSelectionIndicatorColor is on.
DragDropIndicatorColor
Gets or sets the colour of the bar that shows where a dragged header will land.
- Value
- The default is
SystemColors.Highlight.
DrawBorderAroundTabStrip
Gets or sets whether a one-pixel border is drawn round the whole strip.
- Value
- The default is
false.
Remarks
The border is drawn in TabPageBorderColor.
DrawTabPageOnTopOfEachOther
Gets or sets whether neighbouring headers overlap, each slanting over the one before it, with the selected header on top.
- Value
- The default is
false.
Remarks
Always on while TabRenderingStyle is
RenderingStyle.TrapeziumTop; turning it off then has no effect.
DropShadowColor
Gets or sets the colour of the strip's drop shadow.
- Value
- The default is
Color.Black. The colour's alpha is ignored;DropShadowOpacitysets the strength. - Designer category
- Appearance
DropShadowDepth
Gets or sets how far the strip's drop shadow reaches, which is also the width of the band it takes from the strip.
- Value
- The distance in logical pixels, from 0 to 16; values outside that range are clamped. The default is 4.
- Default
DropShadowPainter.DefaultDepth- Designer category
- Appearance
DropShadowOpacity
Gets or sets how dark the strip's drop shadow is at its strongest.
- Value
- From 0 (no shadow) to 255; values outside that range are clamped. The default is 96.
- Default
DropShadowPainter.DefaultOpacity- Designer category
- Appearance
EmptySpaceLengthBeforeTheFirstTabPage
Gets or sets the space left before the first header of each row.
- Value
- The space in logical pixels. The default is 8.
EnableAutomaticUpdateOfTabPagesHeaderSize
Gets or sets whether the header height is recalculated to fit the tallest caption or image whenever the strip's font or a page's image changes.
- Value
- The default is
false.
Remarks
When on, a change to the strip's Control.Font, or to a page's
BinaryPowerTabPage.Image or BinaryPowerTabPage.DisabledImage, sets
TabPageHeaderHeight to the larger of the tallest image and the tallest caption (in the strip's
font) plus a margin. Turning it on does not resize anything by itself. Either way the headers are never drawn
shorter than their font and images need.
EnableControlledLayoutRendering
Gets or sets a layout option that the strip stores but does not act on.
- Value
- The default is
false; neither value changes layout or painting.
EnableDragAndDropOfTabPages
Gets or sets whether users can drag a tab header to a new position.
- Value
- The default is
false.
Remarks
A press becomes a drag once the held pointer moves past the system's drag distance. A bar marks where
the header will land (ShowDragDropIndicator), and on release the page moves there in
TabPages, raising TabPageSelectionChanged with
TabPageChangeTriggerSource.Removed then TabPageChangeTriggerSource.Added. Turning
this off cancels a drag in progress.
See also
EnableTabPageLevelCloseButtonRendering
Gets or sets whether each tab header draws its own close button.
- Value
- The default is
true.
Remarks
A button is drawn on a header whose page has both
BinaryPowerTabPage.ShouldRenderCloseButton and BinaryPowerTabPage.IsHeaderEnabled
on, and the header is widened by 20 logical pixels to make room (see
ReserveCloseButtonSpaceOnAllTabPages). A click raises TabPageClosing; unless it is
cancelled the page is removed and TabPageClosed is raised.
The buttons respond only while ShowCloseWindowButton is also on; with it off they are
drawn but do nothing.
ExtendedWindowsXPRenderingFirstColor
Gets or sets the colour of the thin outer line along the selected header's leading edge in the
RenderingStyle.ExtendedWindowsXP style.
- Value
- The default is
Color.Blue.
Remarks
A two-pixel line in ExtendedWindowsXPRenderingSecondColor runs inside it. The colour is
used from the next repaint.
ExtendedWindowsXPRenderingSecondColor
Gets or sets the colour of the two-pixel inner line along the selected header's leading edge in the
RenderingStyle.ExtendedWindowsXP style.
- Value
- The default is
Color.LightBlue. Used from the next repaint.
GapBetweenTabPages
Gets or sets the space between two neighbouring headers, while
TabPagesHaveGapBetweenThem is on.
- Value
- The space in logical pixels. The default is 8.
- Default
8
HeaderFont
Gets or sets the font of the header text, and gives it to every page.
- Value
- The default is the system's default user-interface font. Setting
nullis ignored.
Remarks
Setting it replaces every page's BinaryPowerTabPage.HeaderTextFont, and a page added
later is given it when it joins the strip; to give one tab its own font, set that page's font afterwards. The
selected tab uses SelectedTabPageHeaderFont.
HeaderTextCloseButtonExtraGap
Gets or sets the extra width added to every header when the headers are auto-sized.
- Value
- The width in logical pixels. The default is 8.
Remarks
Used only while ShouldAutoSizeTabs is on; otherwise
TabPageHeaderHorizontalPadding sets the room round each caption.
IsBackgroundTransparent
Gets or sets whether the strip's background, and its pages', is transparent.
- Value
- The default is
false.
Remarks
Turning it on remembers Control.BackColor and sets it to
Color.Transparent; turning it off restores it. The setting is passed to the pages the strip has
at the time, not to pages added later.
KeepShowingTooltipEvenWhenMousePointerIsMoving
Gets or sets whether the tooltip follows the pointer from header to header, rather than appearing only when the pointer rests.
- Value
- The default is
false.
Remarks
When false, the tooltip appears when the pointer rests on the header it
entered the strip over; moving onto another header hides it, and that header's tooltip appears only
after the pointer has left the strip and come back.
When true, each movement over a header shows that header's tooltip at the
pointer, and leaving the headers hides it.
NewlyAddedPagesAreLocatedAtLeftCorner
Gets or sets a placement preference for new pages that the strip stores but does not use to place them.
- Value
- The default is
false.
Remarks
PagesCurrentlyDisplayedInActiveTabControlView
Gets the tab headers drawn by the last paint, in the order they were drawn.
- Value
- One entry per header drawn; empty unless
ShouldReportCurrentlyDisplayedTabPagesListis on. The same list is cleared and refilled by every paint, so copy it to keep a snapshot.
PowerTabStripElementsRenderer
Gets or sets an object of your own that draws the overflow glyph, in place of the built-in drop-down arrow.
- Value
- The renderer, or
null(the default) for the built-in glyph.
Remarks
The renderer is called only while OverflowMenuGlyphDrawnInEnlargedMode is on. It
draws into a box OverflowMenuGlyphSize in size at the right-hand end of the headers,
and is told whether the pointer is over it (OverflowMenuGlyphVisualState). With a
renderer set, OverflowMenuGlyphSize is not limited to 16 to 32 pixels – set the
renderer first, then the size – so make TabPageHeaderHeight at least as tall as the
glyph.
While a renderer is set, the strip-level close button (ShowCloseWindowButton)
has no place.
Example
public sealed class TabListGlyph : IPowerTabStripElementsRenderer
{
public void RenderOverflowMenuGraphic(Graphics g, Rectangle bounds, OverflowMenuGlyphVisualState state)
{
Color back = state == OverflowMenuGlyphVisualState.Highlighted ? Color.FromArgb(204, 228, 247) : Color.Transparent;
using (var fill = new SolidBrush(back))
{
g.FillRectangle(fill, bounds);
}
TextRenderer.DrawText(g, "All tabs", SystemFonts.MenuFont, bounds, SystemColors.ControlText,
TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
}
}
tabs.OverflowMenuGlyphDrawnInEnlargedMode = true;
tabs.PowerTabStripElementsRenderer = new TabListGlyph();
tabs.OverflowMenuGlyphSize = new Size(72, 24);
tabs.TabPageHeaderHeight = 28;PreventInvalidation
Gets or sets whether changing a page's BinaryPowerTabPage.Text leaves the strip unpainted until
this is turned off again.
- Value
- The default is
false.
Remarks
Set it before renaming many tabs and clear it afterwards; clearing it repaints once. Only text changes are held back.
RenderFullTextForTabPageHeader
Gets or sets how a caption wider than TabPageHeaderWidth is shortened: in the middle,
keeping its start and end, or at the end.
- Value
false(the default) to remove the middle of the caption and put an ellipsis there, so "Quarterly sales forecast.xlsx" keeps both its first words and its file extension;trueto keep the caption from its start and cut it at the end.
Remarks
Either way the text is no wider than TabPageHeaderWidth; raise that to show
long captions in full. The new value is used from the strip's next repaint.
ReserveCloseButtonSpaceOnAllTabPages
Gets or sets whether room for a close button is added to every header, or only to the headers that draw one.
- Value
- The default is
true: every header is widened.
Remarks
While EnableTabPageLevelCloseButtonRendering is on, 20 logical pixels are added
to a header for its close button. A button is drawn only on a page whose
BinaryPowerTabPage.ShouldRenderCloseButton and
BinaryPowerTabPage.IsHeaderEnabled are on, so set this to false when
some pages turn their button off and should not carry the empty room.
Auto-sized headers (ShouldAutoSizeTabs) stay uniform: they all get the room if
any page draws a button.
SelectedPageHeaderTextIsRenderedBold
Gets or sets whether the selected tab's header text is drawn in bold when
SelectedTabPageHeaderFont is not set.
- Value
- The default is
true.
Remarks
Set SelectedTabPageHeaderFont for any other look. Not shown in the designer's
property grid.
SelectedTabPage
Gets or sets the tab whose page is on show.
- Value
- The selected page, or
nullwhen there is none. - Default
null
Remarks
Setting it shows that page, hides the others and raises TabPageSelectionChanged. Setting
null selects the first page instead, if it is
BinaryPowerTabPage.Visible.
In OverflowMode.Menu mode, selecting a page whose header is not on show moves the page to
the front of TabPages so its header comes into view – unless
ShouldRespectTabPageSetupOrderUponSelectedPageChange is on.
SelectedTabPageHeaderFont
Gets or sets the font of the selected tab's header text.
- Value
- The font, or
null(the default) to derive it; the getter then returnsHeaderFontin bold.
Remarks
Left unset, the selected header uses the page's own BinaryPowerTabPage.HeaderTextFont,
in bold while SelectedPageHeaderTextIsRenderedBold is on. Not used while
TabPageHeaderTextFontOverridesControlDefault is on. The header height grows, if it must, to fit
this font.
ShouldAutoSizeTabs
Gets or sets whether every header is given the same width – that of the widest.
- Value
- The default is
false: each header is as wide as its own caption.
Remarks
When on, each header is as wide as the widest caption and image, plus
HeaderTextCloseButtonExtraGap, the close button's room and 20 logical pixels.
TabPageHeaderHorizontalPadding does not apply.
ShouldDrawDropShadow
Gets or sets whether the strip casts a drop shadow along its bottom and right-hand edges.
- Value
- The default is
false. - Default
false- Designer category
- Appearance
Remarks
A child control cannot paint outside itself, so the shadow is drawn in a band inside the
strip's bounds, and the room for the headers and pages shrinks by DropShadowDepth on
those two edges. The part of the band the shadow does not cover is filled with the colour of the
nearest opaque container behind the strip.
See also
ShouldDrawTabHeaderDropShadow
Gets or sets whether each tab header casts a soft drop shadow down and to the right, the selected header's falling over its neighbours.
- Value
- The default is
false. - Default
false- Designer category
- Appearance
Remarks
Each shadow follows its header's own outline. When the headers overlap
(DrawTabPageOnTopOfEachOther, always the case with
RenderingStyle.TrapeziumTop), only the selected header casts one.
Separate from ShouldDrawDropShadow, which shadows the whole strip; either, both
or neither may be on.
Example
tabs.ShouldDrawTabHeaderDropShadow = true;
tabs.TabHeaderDropShadowDepth = 4;
tabs.TabHeaderDropShadowOpacity = 60;ShouldDrawTabPageHeaderInMultiLines
Gets or sets whether a header's text may run onto more than one line.
- Value
- The default is
false: each caption is drawn on one line.
Remarks
When on, line breaking is left to TabHeaderStringFormat, so a caption wider
than TabPageHeaderWidth can wrap; make TabPageHeaderHeight tall enough
to show the extra lines.
ShouldEnableControlDiagnosticsReporting
Gets or sets whether the strip writes a report of the headers on show to
Trace when the pointer enters or leaves it.
- Value
- The default is
false. Reports only whileShouldReportCurrentlyDisplayedTabPagesListis also on.
ShouldReportCurrentlyDisplayedTabPagesList
Gets or sets whether each paint records the headers it drew in
PagesCurrentlyDisplayedInActiveTabControlView.
- Value
- The default is
false. A diagnostic aid, hidden from the designer.
ShouldRespectTabPageSetupOrderUponSelectedPageChange
Gets or sets whether selecting a tab whose header is out of view keeps the tabs in their order.
- Value
- The default is
false.
Remarks
Applies in OverflowMode.Menu mode, when a page is chosen from the overflow menu
or set as SelectedTabPage while its header is not on show.
false– the page is moved to the front ofTabPages, so its header becomes the first one shown.true– the order is kept, and the headers on show shift along so the selected one is the last in view.
ShouldUpdateUponParentMove
Gets or sets whether the selected page is repainted at once whenever the form the strip is on is moved.
- Value
- The default is
false.
ShouldUpdateUponParentResize
Gets or sets whether the selected page is repainted at once whenever the form the strip is on is resized.
- Value
- The default is
false.
Remarks
The headers are laid out again after a resize either way; this also repaints the page's contents straight away, for pages whose controls draw themselves from the page's size.
ShowCloseWindowButton
Gets or sets whether the strip-level close button, at the right-hand end of the headers, closes the selected tab when clicked.
- Value
- The default is
true. - Default
true
Remarks
The button occupies a 16-logical-pixel square to the right of the overflow glyph, and has no place
while OverflowMenuGlyphDrawnInEnlargedMode is on or a
PowerTabStripElementsRenderer is set. It is drawn only in the designer; at run time a click on
its place still closes the tab. The close buttons on the headers also respond only while this is on.
ShowDragDropIndicator
Gets or sets whether a header being dragged shows where it will land: a bar between two headers, with a caret
at each end, in DragDropIndicatorColor.
- Value
- The default is
true. - Default
true
Remarks
The bar is shown only where a drop would move the page; outside the headers the pointer shows that a drop does nothing.
ShowToolTip
Gets or sets whether a page's BinaryPowerTabPage.ToolTipText is shown when the pointer
rests on its header.
- Value
- The default is
true.
See also
Size
Gets or sets the size of the strip, and lays the headers out again for the new size.
- Value
- The size in pixels. The default is 300 by 250.
- Default
300,250
TabBottomOrientationCloseButtonPosition
Gets or sets whether a header's close button sits near its top or its bottom edge when the tabs run along the bottom of the strip.
- Value
- The default is
CloseButtonPosition.Bottom.
Remarks
Applies only while TabPagesRenderingLocation is
TabPagesRenderingLocation.Bottom, and not to RenderingStyle.TrapeziumTop
headers.
TabHeaderDropShadowColor
Gets or sets the colour of the tab headers' drop shadows.
- Value
- The default is
Color.Black. The colour's alpha is ignored;TabHeaderDropShadowOpacitysets the strength. - Default
Black- Designer category
- Appearance
TabHeaderDropShadowDepth
Gets or sets how far each tab header's drop shadow reaches.
- Value
- The distance in logical pixels, from 0 to 16; values outside that range are clamped. The default is 3. At 0 no shadow is drawn.
- Default
3- Designer category
- Appearance
TabHeaderDropShadowOpacity
Gets or sets how dark the tab headers' drop shadows are at their strongest.
- Value
- From 0 (no shadow) to 255 (solid
TabHeaderDropShadowColor); values outside that range are clamped. The default is 80. - Default
80- Designer category
- Appearance
TabHeaderStringFormat
Gets or sets the text layout used to measure and draw the header captions.
- Value
- The default centres the caption both ways.
Remarks
The strip adjusts the format's trimming and line-breaking flags as it lays out and paints
(see RenderFullTextForTabPageHeader and
ShouldDrawTabPageHeaderInMultiLines), and disposes the format it holds when it is
disposed, so give it a format of its own rather than one shared with other code. The new format is
used from the next repaint.
TabPageBorderColor
Gets or sets the colour of the headers' outline and of the border round the strip.
- Value
- The default is
SystemColors.ControlDark.
Remarks
In the RenderingStyle.VisualStudio2008 style the strip sets this colour
itself as it paints, unless ThemeBorderColorCanBeOverridden is on; turn that on to
keep a colour of your own. The new colour is used from the next repaint.
See also
TabPageCloseButtonMouseEnterColor
Gets or sets the colour a header's close-button cross turns while the pointer is over it.
- Value
- The default is
Color.Red.
See also
TabPageCloseButtonRectangleBorderColor
Gets or sets the outline of the box drawn behind the strip-level close button while the pointer is over it.
- Value
- The default is
SystemColors.Highlight.
See also
TabPageCloseButtonRectangleFillColor
Gets or sets the fill of the box drawn behind the strip-level close button while the pointer is over it.
- Value
- The default is
SystemColors.Highlight.
Remarks
The close buttons on the headers do not draw this box.
See also
TabPageCurrentSelectionIndicatorEndColor
Gets or sets the colour the selected header's fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Color.White.
TabPageCurrentSelectionIndicatorStartColor
Gets or sets the colour the selected header's fill starts from in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Color.Orange.
Remarks
The fill runs to TabPageCurrentSelectionIndicatorEndColor in the direction of
TabPageHeaderDrawingGradientOrientation, while
UseTabCurrentSelectionIndicatorColor is on.
TabPageHeaderDrawingGradientOrientation
Gets or sets the direction of the header fill's gradient in the RenderingStyle.Custom
and RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Vertical: from the top of the header to the bottom.
TabPageHeaderForeColor
Gets or sets the colour of the header text.
- Value
- The default is
SystemColors.WindowText.
Remarks
A page's own BinaryPowerTabPage.TabPageHeaderForeColor, when set, takes
precedence. The text of an unselected header whose page has
BinaryPowerTabPage.IsHeaderEnabled off is drawn in
SystemColors.GrayText.
TabPageHeaderHeight
Gets or sets the height of a row of tab headers.
- Value
- The height in logical pixels. The default is 24.
Remarks
The headers are never drawn shorter than their text needs – the selected tab's font height plus 11 logical pixels – nor than the tallest page image needs, so a larger font or image makes them taller without this value changing. A value larger than both is used as it is.
The page area starts below the headers (above them when
TabPagesRenderingLocation is TabPagesRenderingLocation.Bottom), and in
OverflowMode.MultiLine mode each row of headers takes this height. Unless
TabPageHeaderHorizontalPadding is set, each header is also this much wider than its
text.
Example
// Taller headers for a touch-friendly screen.
tabs.TabPageHeaderHeight = 36;See also
TabPageHeaderHorizontalPadding
Gets or sets the room added to each header's width on top of its text – the space that frames the caption.
- Value
- The padding in logical pixels, or -1 (the default) to use the header height
(
TabPageHeaderHeight). Any negative value is stored as -1.
Remarks
Lower it to make every tab narrower without changing the font, so more headers fit before the overflow menu is needed.
Applies while ShouldAutoSizeTabs is off. Auto-sized tabs all take the width of
the widest, and HeaderTextCloseButtonExtraGap sets their extra room instead.
Example
// Compact tabs: 12 logical pixels round each caption instead of the header height.
tabs.TabPageHeaderHorizontalPadding = 12;TabPageHeaderShowsSideBar
Gets or sets whether each header carries a coloured bar along its right-hand edge in the
RenderingStyle.Custom style.
- Value
- The default is
false.
Remarks
Drawn only in RenderingStyle.Custom with the tabs along the top, in the page's
BinaryPowerTabPage.TabPageSideBarFillColor when set and otherwise the strip's
TabPageSideBarFillColor. A value set while TabPagesRenderingLocation is
TabPagesRenderingLocation.Bottom is ignored, so set the location first.
TabPageHeaderTextFontOverridesControlDefault
Gets or sets whether the selected tab's header text is drawn in its page's own
BinaryPowerTabPage.HeaderTextFont, like the other headers, rather than in the
selected-tab font.
- Value
- The default is
false: the selected tab usesSelectedTabPageHeaderFont, which is bold unless set otherwise.
Remarks
With this on, SelectedTabPageHeaderFont and
SelectedPageHeaderTextIsRenderedBold are not used. The new value is used from the
strip's next repaint.
TabPageHeaderWidth
Gets or sets the widest a header's text may be; longer captions are shortened with an ellipsis.
- Value
- The width in logical pixels. The default is 200.
Remarks
A header is as wide as its text up to this width, plus its padding, image and close button.
How a longer caption is shortened depends on RenderFullTextForTabPageHeader.
Changing it lays the headers out again at once.
See also
TabPageSideBarFillColor
Gets or sets the colour of the side bar on each header, when TabPageHeaderShowsSideBar
is on.
- Value
- The default is orange, RGB (255, 128, 0).
Remarks
A page's own BinaryPowerTabPage.TabPageSideBarFillColor, when set, takes
precedence for that page.
TabPages
Gets the strip's pages, in tab order.
- Value
- The collection of pages; never
null. Adding or removing a page adds or removes its tab.
TabPagesCloseButtonColor
Gets or sets the colour of the cross on the close buttons.
- Value
- The default is
SystemColors.WindowText;SystemColors.GrayTextis used while the strip has no pages.
See also
TabPagesHaveGapBetweenThem
Gets or sets whether the headers are spaced apart by GapBetweenTabPages rather than
drawn edge to edge.
- Value
- The default is
false.
TabPagesOverflowCalculationStrategy
Gets or sets how many auto-sized tabs the strip assumes fit on a row when it fills rows by counting tabs rather than measuring them.
- Value
- The default is
TabPagesOverflowCalculationStrategy.Pessimistic.
Remarks
Matters only while ShouldAutoSizeTabs is on and the rows are counted by tab
width rather than measured – that is, with UseLegacyMultiLineRowPacking on.
TabPagesOverflowCalculationStrategy.Pessimistic allows one tab fewer per row than
would fit; TabPagesOverflowCalculationStrategy.Optimistic allows as many as fit.
Setting it lays the strip out again.
TabPagesRenderingLocation
Gets or sets whether the tab headers run along the top or the bottom of the strip.
- Value
- The default is
TabPagesRenderingLocation.Top.
Remarks
The page area moves to the other side of the headers. With the headers at the bottom,
TabBottomOrientationCloseButtonPosition places the close buttons, and the side bar
(TabPageHeaderShowsSideBar) is not drawn.
TabRenderingStyle
Gets or sets the shape and colouring of the tab headers.
- Value
- One of the
RenderingStylevalues. The default isRenderingStyle.VisualStudio2008.
Remarks
The Visual Studio and Windows XP styles have fixed colours.
RenderingStyle.Custom and RenderingStyle.TrapeziumTop fill the headers
from CustomStartColor to CustomEndColor (or a page's own
BinaryPowerTabPage.CustomStartColor and
BinaryPowerTabPage.CustomEndColor), and the selected header from the selection colours
(UseTabCurrentSelectionIndicatorColor).
Choosing RenderingStyle.TrapeziumTop also turns on
DrawTabPageOnTopOfEachOther, which stays on if another style is chosen later. Setting
this property does not raise TabStyleRenderingStyleChanged.
Example
tabs.TabRenderingStyle = RenderingStyle.Custom;
tabs.CustomStartColor = Color.FromArgb(225, 236, 248);
tabs.CustomEndColor = Color.White;
tabs.TabPageCurrentSelectionIndicatorStartColor = Color.FromArgb(0, 120, 215);
tabs.TabPageCurrentSelectionIndicatorEndColor = Color.FromArgb(153, 201, 239);TabsOverflowMode
Gets or sets what the strip does when the headers are wider than it is: keep one row and list the tabs in a drop-down menu, or wrap them onto extra rows.
- Value
- The default is
OverflowMode.Menu.
Remarks
In OverflowMode.Menu mode as many headers are shown as fit, always including the
selected one, and a glyph at the right-hand end (ShowOverflowMenuGlyph) lists every visible tab
whose header is enabled. In OverflowMode.MultiLine mode every header is shown, the page area
shrinks by one TabPageHeaderHeight per extra row, and there is no glyph.
See also
ThemeBorderColorCanBeOverridden
Gets or sets whether border colours you set are kept in the styles that otherwise set their own.
- Value
- The default is
false.
Remarks
While this is off, the RenderingStyle.VisualStudio2008,
RenderingStyle.WindowsXP and RenderingStyle.ExtendedWindowsXP styles set
each page's BinaryExtendedPanel.BorderColor as they paint, and the Visual Studio 2008
style also sets TabPageBorderColor.
ToolTipConfiguration
Gets or sets how the tab headers' tooltips look and behave: their delays, colours, icon, title and style.
- Value
- The settings object. The default is a new one, with the defaults its properties list. Do not
set
null.
Remarks
The settings are applied each time a tooltip is shown, so changing a property of the
current object takes effect at the next tooltip. The text of each tooltip is the page's
BinaryPowerTabPage.ToolTipText.
Example
tabs.ToolTipConfiguration.IsBalloon = true;
tabs.ToolTipConfiguration.ToolTipIcon = ToolTipIcon.Info;
tabs.ToolTipConfiguration.ToolTipTitle = "Document";
tabs.ToolTipConfiguration.InitialDelay = 300;See also
UseLegacyMultiLineRowPacking
Gets or sets whether the rows of headers in OverflowMode.MultiLine mode are filled by
counting tabs rather than by measuring them.
- Value
- The default is
false.
Remarks
With false, each row takes as many headers as genuinely fit, measured at the
width each is painted at.
With true, every header is assumed to be TabPageHeaderWidth
wide, so rows usually hold fewer tabs than would fit and wrap earlier. Use it only to keep a layout
that depends on that rule.
UseTabCurrentSelectionIndicatorColor
Gets or sets whether the selected header is filled with the selection colours in the
RenderingStyle.Custom and RenderingStyle.TrapeziumTop styles.
- Value
true(the default) to fill it fromTabPageCurrentSelectionIndicatorStartColortoTabPageCurrentSelectionIndicatorEndColor;falseto use the custom colours, as the other headers do.
Methods
AddTab
Adds a page as the last tab, without selecting it.
Parameters
tabPage- The page to add. A page already in the strip is not added twice;
nullis ignored.
Remarks
The page is docked to fill the page area and TabPageSelectionChanged is
raised with TabPageChangeTriggerSource.Added. The first page added to an empty strip
is selected when the strip next paints.
See also
AddTab
Adds a page as the last tab, and selects it if asked to.
Parameters
tabPage- The page to add.
nullis ignored. selectThisTabPageafterAddtrueto make the new page theSelectedTabPage.
Remarks
Raises TabPageSelectionChanged with
TabPageChangeTriggerSource.Added, and again with
TabPageChangeTriggerSource.SelectionChanged when the page is selected.
AddTab
Adds a page as the first or the last tab, and selects it if asked to.
Parameters
tabPage- The page to add.
nullis ignored. selectThisTabPageafterAddtrueto make the new page theSelectedTabPage.positionThisNewPageInTheLeftHandCornertrueto put the page first inTabPages, at the left-hand end of the headers;falseto put it last.
Example
// A new search result opens as the first tab, and is shown straight away.
var results = new BinaryPowerTabPage { Text = "Results: \"overdue invoices\"" };
results.Controls.Add(resultsGrid);
tabs.AddTab(results, true, true);Dispose
Releases the strip's resources, disposing every page it holds, the overflow menu and the tooltip.
Parameters
disposingtruewhen called fromDispose;falsefrom the finalizer.
GetDisabledImageFromNormal static
Makes a grey copy of an image, as a disabled header draws its page's image when it has no
BinaryPowerTabPage.DisabledImage.
Parameters
normalImage- The image to copy; it is not changed. Must not be
null.
Returns
A new bitmap, in shades of grey, with the colour of its top-left pixel made transparent. The caller disposes it.
GetTabPageByPoint
Gets the tab whose header is at a point.
Parameters
pt- The point, in the strip's client coordinates.
Returns
The page whose header contains the point, or null if there is none. Only
headers on show count.
See also
HitTest
Tells which part of the strip is at a point: a header, a header's close button, the overflow glyph, the strip-level close button, or none of them.
Parameters
pt- The point, in the strip's client coordinates (as in
MouseEventArgs.Location).
Returns
The part at the point. A point on a header whose page has
BinaryPowerTabPage.IsHeaderEnabled off, or on a button that is switched off, gives
HitTestArea.None. Never throws.
Remarks
Headers are tested where they were last painted, so a header that is not on show is never hit.
Example
tabs.MouseUp += (sender, e) =>
{
// A right-click on a header offers that tab's own menu.
if (e.Button == MouseButtons.Right && tabs.HitTest(e.Location) == HitTestArea.TabPage)
{
tabContextMenu.Tag = tabs.GetTabPageByPoint(e.Location);
tabContextMenu.Show(tabs, e.Location);
}
};See also
OnCreateControl
Starts watching the form and containers around the strip, for a strip added to a form that already exists, then carries on as the base class does.
OnDoubleClick
Raises TabPageDoubleClicked for a double-click on a header, and the
Control.DoubleClick event for a double-click anywhere else.
Parameters
e- The event data.
Remarks
A double-click on a header, a close button or the overflow glyph does not raise
Control.DoubleClick.
OnFontChanged
Raises the Control.FontChanged event, and recalculates the header height when
EnableAutomaticUpdateOfTabPagesHeaderSize is on.
Parameters
e- The event data.
OnHandleCreated
Raises the Control.HandleCreated event, and starts watching the form and containers around the
strip so the headers are laid out again when they resize.
Parameters
e- The event data.
OnHandleDestroyed
Stops watching the form and containers around the strip, then raises the Control.HandleDestroyed
event.
Parameters
e- The event data.
OnKeyDown
Selects the next tab when Ctrl+Tab reaches the strip, then raises the Control.KeyDown
event.
Parameters
e- The event data.
Remarks
The next tab is the next page in TabPages; on the last page, Ctrl+Tab does
nothing.
OnLayout
Raises the Control.Layout event, and at run time works out again how many headers fit.
Parameters
e- The event data.
OnMouseCaptureChanged
Raises the Control.MouseCaptureChanged event, and abandons a header drag whose capture
was taken away while the button is still down – by a window activated from the keyboard, or a dialog
- so nothing is dropped later and no bar is left behind.
Parameters
e- The event data.
OnMouseDown
Raises the Control.MouseDown event, then acts on a left-button press: selects the tab
under the pointer, opens the overflow menu, or closes a tab whose close button was pressed.
Parameters
e- The event data.
OnMouseEnter
Raises the Control.MouseEnter event, and notes the header the pointer entered over,
for its tooltip.
Parameters
e- The event data.
OnMouseHover
Raises the Control.MouseHover event, and shows the tooltip of the header under the
pointer.
Parameters
e- The event data.
OnMouseLeave
Raises the Control.MouseLeave event, hides any tooltip and clears the highlights on
the buttons.
Parameters
e- The event data.
OnMouseMove
Raises the Control.MouseMove event, then carries a header drag along, or updates the
tooltips and the highlights on the close buttons and the overflow glyph.
Parameters
e- The event data.
OnMouseUp
Raises the Control.MouseUp event, and drops a header being dragged at the place the
drop bar shows.
Parameters
e- The event data.
OnPaint
Paints the headers, the overflow glyph and any drop bar; the Control.Paint event is not
raised.
Parameters
e- The event data.
OnParentBackColorChanged
Raises the Control.ParentBackColorChanged event, and repaints the drop-shadow band,
which shows the colour behind the strip.
Parameters
e- The event data.
OnParentChanged
Raises the Control.ParentChanged event, and starts watching the strip's new form and
containers when it is moved to another parent at run time.
Parameters
e- The event data.
OnResize
Raises the Control.Resize event, and resizes the page area to the room the headers
leave.
Parameters
e- The event data.
OnSizeChanged
Raises the Control.SizeChanged event, then works out again how many headers fit and
lays them out for the new size.
Parameters
e- The event data.
OnSystemColorsChanged
Raises the Control.SystemColorsChanged event and repaints the strip, whose default colours come
from the system palette.
Parameters
e- The event data.
OnTabStyleRenderingStyleChanged
Raises the TabStyleRenderingStyleChanged event.
Parameters
e- The event data.
RearrangeTabPageLocation
Moves a page to a new position among the tabs.
Parameters
pageToMove- The page to move. A page that is not one of this strip's is ignored.
destinationIndexToMoveTheDesiredTabPageTo- The zero-based position the page is to take in
TabPages.
Exceptions
System.ArgumentOutOfRangeException- The position is negative or past the last page.
Remarks
Does nothing on a strip with no pages. The page is taken out and put back, so
TabPageSelectionChanged is raised twice: TabPageChangeTriggerSource.Removed, then
TabPageChangeTriggerSource.Added.
RefreshLayout
Lays the headers and the page area out again from scratch.
Remarks
Call it after a change the strip does not watch – for example a page's
BinaryPowerTabPage.HeaderTextFont, which does not lay the headers out again by
itself.
See also
RemoveTab
Removes a page from the strip and selects a neighbouring tab.
Parameters
tabPage- The page to remove.
Remarks
The page is removed from TabPages (raising TabPageSelectionChanged
with TabPageChangeTriggerSource.Removed) but is not disposed. Then, while pages
remain, the page that was just before it is selected – the first visible page if it was the first –
whether or not the removed page was the selected one. With Control.RightToLeft on, the
page after it is selected instead.
Neither TabPageClosing nor TabPageClosed is raised.
ResetExternal
Does nothing. Calling it has no effect on the strip.
See also
ResetInvalidate
Works out again how many headers fit, lays the strip out and repaints it.
Remarks
Use it after a change that affects how many headers fit in OverflowMode.Menu
mode, such as new captions on several pages.
See also
SetBoundsCore
Sets the strip's bounds with layout suspended on the strip and every control inside it, so the pages are laid out once for the new size.
Parameters
x- The new left edge, in pixels.
y- The new top edge, in pixels.
width- The new width, in pixels.
height- The new height, in pixels.
specified- Which of the bounds are being set.
ShouldSerializeFont
Tells the designer whether to write Control.Font into the designer file: only when it differs
from the system's default font.
ShouldSerializeItems
Part of the designer's serialisation support; not for use from application code. Returns
true when the strip has pages.
ShouldSerializeSelectedItem
Part of the designer's serialisation support; not for use from application code. Always returns
true.
WndProc
Processes the strip's window messages, reserving and painting the drop-shadow band when
ShouldDrawDropShadow is on.
Parameters
m- The message.
Remarks
The band is part of the window's non-client area, along the right and bottom edges, so the headers, the border and the pages all cast the shadow.
Events
TabElementsLayoutChanging
Occurs just before the strip lays its headers out again.
Remarks
The event data is the name of the member whose change set off the layout – for example
"TabPageHeaderHeight", "Size" or "OnSizeChanged" – so a handler can react to
some causes and not others.
Do not set the member named in the event data from the handler: that starts another layout, and raises the event again.
Example
tabs.TabElementsLayoutChanging += (sender, changedMember) =>
{
if (changedMember == nameof(BinaryPowerTabStrip.TabPageHeaderHeight))
{
statusLabel.Text = "Header height changed";
}
};TabPageClosed
Occurs after the user has closed a tab with a close button and its page has been removed.
Remarks
The event data does not say which page; note it in TabPageClosing if needed.
TabPageClosing
Occurs when the user clicks a close button, before the page is removed; a handler can cancel.
Remarks
TabPageClosingEventArgs.TabPage is the page about to close. Set
Cancel to keep it; otherwise it is removed with
RemoveTab and TabPageClosed follows. Removing a page from code does not raise this
event.
TabPageDoubleClicked
Occurs when the user double-clicks a tab header.
Remarks
Not raised for a header whose page has BinaryPowerTabPage.IsHeaderEnabled
off, nor for the close buttons or the overflow glyph.
Example
// Double-clicking a tab opens its document in a window of its own.
tabs.TabPageDoubleClicked += (sender, e) => OpenInNewWindow(e.TabPage);TabPageSelectionChanged
Occurs when the selected tab changes, and also when a page is added, removed or changed.
Remarks
TabPageChangedEventArgs.TabPageChangeType tells the cases apart:
TabPageChangeTriggerSource.SelectionChanged– another tab was selected, by the user or throughSelectedTabPage; the page isnullif none could be.TabPageChangeTriggerSource.Added,TabPageChangeTriggerSource.Removed– a page joined or leftTabPages; moving a page raises both.TabPageChangeTriggerSource.Changed– a page'sBinaryPowerTabPage.Visiblechanged, or pages were added withBinaryPowerTabPageCollection.AddRange(pagenull).
TabStyleRenderingStyleChanged
Occurs when OnTabStyleRenderingStyleChanged is called.
Remarks
The strip does not call it itself – setting TabRenderingStyle does not raise this event
- so it is raised only by a derived class.