Power Tab Strip
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.
Assembly
| Assembly | Binarymission.WinForms.Controls.BinaryPowerTabStrip.dll |
| Root namespace | Binarymission.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 BinaryExtendedPanel | The panel BinaryPowerTabPage is built on: a Panel that draws a one-pixel border of its own in BorderColor. |
class BinaryPowerTabPage | One 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 BinaryPowerTabPageCollection | The pages of a BinaryPowerTabStrip, in tab order, as returned by TabPages. |
class BinaryPowerTabPageCollectionBase | The base of BinaryPowerTabPageCollection, raising an event before and after each change to the collection. |
class 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. |
class CurrentlyDisplayedTabPagesListReport | One header drawn by the strip's last paint, as listed by PagesCurrentlyDisplayedInActiveTabControlView. |
class TabPageDoubleClickedEventArgs | Provides data for the TabPageDoubleClicked event. |
enum CloseButtonPosition | Says where a header's close button sits when the tabs run along the bottom of a BinaryPowerTabStrip (TabBottomOrientationCloseButtonPosition). |
enum HitTestArea | Names the part of a BinaryPowerTabStrip at a point, as reported by HitTest. |
interface IPowerTabStripElementsRenderer | Draws the overflow glyph of a BinaryPowerTabStrip in a design of your own. Assign an instance to PowerTabStripElementsRenderer. |
enum OverflowMenuGlyphVisualState | The states a custom overflow glyph is drawn in (IPowerTabStripElementsRenderer). |
enum OverflowMode | Says what a BinaryPowerTabStrip does when its headers are wider than it is (TabsOverflowMode). |
enum RenderingStyle | The header styles a BinaryPowerTabStrip can draw (TabRenderingStyle). |
enum TabPageChangeTriggerSource | Says what raised TabPageSelectionChanged (TabPageChangeType). |
class TabPageChangedEventArgs | Provides data for the TabPageSelectionChanged event: the page concerned, and what happened to it. |
delegate TabPageChangedHandler | Represents a method that handles TabPageSelectionChanged. |
class TabPageClosingEventArgs | Provides data for the TabPageClosing event: the tab about to close, and a way to keep it open. |
delegate TabPageClosingHandler | Represents a method that handles TabPageClosing. |
delegate TabPagesCollectionChangeHandler | Represents a method that handles the events a tab page collection raises as a page is added or removed. |
delegate TabPagesCollectionClearHandler | Represents a method that handles the Clearing and Cleared events. |
enum TabPagesOverflowCalculationStrategy | How many auto-sized tabs a BinaryPowerTabStrip assumes fit on a row when it counts rows by tab width (TabPagesOverflowCalculationStrategy). |
enum TabPagesRenderingLocation | Says which edge of a BinaryPowerTabStrip the tab headers run along (TabPagesRenderingLocation). |
class ToolTipConfiguration | The 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 ToolTipConfigurationTypeConverter | Lets the property grid expand a ToolTipConfiguration into its individual settings instead of showing it as one value. |
Binarymission.WinForms.Controls.TabControls.Designers
class BinaryPowerTabPageDesigner | Visual 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 BinaryPowerTabStripDesigner | Visual 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. |