HypernovaDesktop Components · docs
Binarymission
WinForms › Power Tab Strip

Power Tab Strip

.NET Framework 4.8.NET 6 / 8 / 10v8.0.2WinForms

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.

26public types
268public members
2namespaces

Assembly

AssemblyBinarymission.WinForms.Controls.BinaryPowerTabStrip.dll
Root namespaceBinarymission.WinForms.Controls.TabControls
Target frameworks.NET Framework 4.8, .NET 6 / 8 / 10

Overview

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.

Getting started

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);

API reference

Binarymission.WinForms.Controls.TabControls

class BinaryExtendedPanelThe panel BinaryPowerTabPage is built on: a Panel that draws a one-pixel border of its own in BorderColor.
class BinaryPowerTabPageOne tab of a BinaryPowerTabStrip: a panel for the tab's controls, together with everything its header shows - caption, image, tooltip, colours and close button.
class BinaryPowerTabPageCollectionThe pages of a BinaryPowerTabStrip, in tab order, as returned by TabPages.
class BinaryPowerTabPageCollectionBaseThe base of BinaryPowerTabPageCollection, raising an event before and after each change to the collection.
class BinaryPowerTabStripA 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.
class CurrentlyDisplayedTabPagesListReportOne header drawn by the strip's last paint, as listed by PagesCurrentlyDisplayedInActiveTabControlView.
class TabPageDoubleClickedEventArgsProvides data for the TabPageDoubleClicked event.
enum CloseButtonPositionSays where a header's close button sits when the tabs run along the bottom of a BinaryPowerTabStrip (TabBottomOrientationCloseButtonPosition).
enum HitTestAreaNames the part of a BinaryPowerTabStrip at a point, as reported by HitTest.
interface IPowerTabStripElementsRendererDraws the overflow glyph of a BinaryPowerTabStrip in a design of your own. Assign an instance to PowerTabStripElementsRenderer.
enum OverflowMenuGlyphVisualStateThe states a custom overflow glyph is drawn in (IPowerTabStripElementsRenderer).
enum OverflowModeSays what a BinaryPowerTabStrip does when its headers are wider than it is (TabsOverflowMode).
enum RenderingStyleThe header styles a BinaryPowerTabStrip can draw (TabRenderingStyle).
enum TabPageChangeTriggerSourceSays what raised TabPageSelectionChanged (TabPageChangeType).
class TabPageChangedEventArgsProvides data for the TabPageSelectionChanged event: the page concerned, and what happened to it.
delegate TabPageChangedHandlerRepresents a method that handles TabPageSelectionChanged.
class TabPageClosingEventArgsProvides data for the TabPageClosing event: the tab about to close, and a way to keep it open.
delegate TabPageClosingHandlerRepresents a method that handles TabPageClosing.
delegate TabPagesCollectionChangeHandlerRepresents a method that handles the events a tab page collection raises as a page is added or removed.
delegate TabPagesCollectionClearHandlerRepresents a method that handles the Clearing and Cleared events.
enum TabPagesOverflowCalculationStrategyHow many auto-sized tabs a BinaryPowerTabStrip assumes fit on a row when it counts rows by tab width (TabPagesOverflowCalculationStrategy).
enum TabPagesRenderingLocationSays which edge of a BinaryPowerTabStrip the tab headers run along (TabPagesRenderingLocation).
class ToolTipConfigurationThe look and timing of the tooltips a BinaryPowerTabStrip shows over its headers - the settings of a ToolTip, held where the designer can edit them.
class ToolTipConfigurationTypeConverterLets the property grid expand a ToolTipConfiguration into its individual settings instead of showing it as one value.

Binarymission.WinForms.Controls.TabControls.Designers

class BinaryPowerTabPageDesignerVisual Studio designer support for a BinaryPowerTabPage: lets controls be dropped onto the page, keeps the page inside a tab strip, and hides the inherited properties the strip manages itself.
class BinaryPowerTabStripDesignerVisual Studio designer support for a BinaryPowerTabStrip: a first tab for a new strip, commands to add and remove tabs, smart-tag settings, and clicking a header to select its tab on the design surface.