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.
public class BinaryPowerTabPage : BinaryExtendedPanel
Inherits from / implements: BinaryExtendedPanel
Remarks
Put the tab's controls in the page's Control.Controls, usually one control
docked to fill it, and add the page to a strip with
BinaryPowerTabStrip.AddTab() or
BinaryPowerTabStrip.TabPages. The strip docks the page and shows it while its tab is
selected. A page belongs in a strip: given any other kind of parent it throws
InvalidCastException.
The header
The caption is Text and the picture Image. Colours left empty –
TabPageHeaderForeColor, CustomStartColor, CustomEndColor,
TabPageSideBarFillColor – fall back to the strip's. IsHeaderEnabled
greys a header out so it cannot be clicked, and Visible takes the tab off the strip
altogether.
Examples
var overdue = new BinaryPowerTabPage
{
Text = "Overdue invoices",
Image = Image.FromFile(@"Icons\invoice-warning-16.png"),
ToolTipText = "Invoices more than 30 days past their due date",
TabPageHeaderForeColor = Color.Firebrick,
ShouldRenderCloseButton = false // this tab cannot be closed
};
overdue.Controls.Add(new DataGridView { Dock = DockStyle.Fill, DataSource = overdueInvoices });
tabs.AddTab(overdue, true);See also
Members at a glance
| Constructors | |
|---|---|
BinaryPowerTabPage | Creates a page with no caption, a window-coloured background and a one-pixel border, its header enabled and showing a close button. |
BinaryPowerTabPage | Creates a page with the given caption, its header enabled and showing a close button. |
| Properties | |
BorderSize | Gets or sets the width of the border the page draws round its content area, in
BinaryExtendedPanel.BorderColor. |
CurrentlySelected | Gets or sets a flag the strip keeps in step with the selection: true while this is
the selected tab. |
CustomEndColor | Gets or sets the colour this header's fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles. |
CustomStartColor | Gets or sets the colour this header's fill starts from in the RenderingStyle.Custom
and RenderingStyle.TrapeziumTop styles. |
DisabledImage | Gets or sets the picture drawn in place of Image while this tab's header is disabled. |
HeaderTextFont | Gets or sets the font of this tab's header text. |
Image | Gets or sets the picture drawn before the caption in this tab's header. |
IsBackgroundTransparent | Gets or sets whether the page's background is transparent, so whatever is behind the strip shows through. |
IsHeaderEnabled | Gets or sets whether this tab's header can be clicked. |
OverflowMenuImage | Gets or sets the image shown beside this tab's entry in the strip's overflow menu. |
ShouldRenderCloseButton | Gets or sets whether this tab's header shows a close button. |
Size | Gets or sets the size of the page. The strip sizes its pages to fill the page area, so this is hidden from the designer and the editor's completion lists. |
TabPageContentIsDirty | Gets or sets whether the page holds changes the user has not saved – a flag for your own code. |
TabPageHeaderForeColor | Gets or sets the colour of this tab's header text. |
TabPageSideBarFillColor | Gets or sets the colour of this header's side bar, when the strip draws side bars. |
Text | Gets or sets the caption shown in this tab's header and in the overflow menu. |
ToolTipText | Gets or sets the tooltip shown when the pointer rests on this tab's header. |
Visible | Gets or sets whether this tab is on the strip at all – its header drawn and listed in the overflow menu. |
| Methods | |
Dispose | Releases the page's resources, including its Image. |
OnPaint | Draws the page's border (BorderSize, BinaryExtendedPanel.BorderColor),
then raises the Control.Paint event. |
OnParentChanged | Raises the Control.ParentChanged event, and takes the new strip's
BinaryPowerTabStrip.HeaderFont as HeaderTextFont. |
ShouldSerializeControls | Tells the designer to write the page's child controls into the designer file when it has any. |
ShouldSerializeDock | Tells the designer not to write Control.Dock into the designer file: the strip docks
its pages itself. Always returns false. |
ShouldSerializeIsPaintingComplete | Part of the designer's serialisation support; not for use from application code. Always returns
false. |
ShouldSerializeVisible | Tells the designer always to write Visible into the designer file. Always returns
true. |
| Events | |
TabPageChanged | Occurs when the page's Visible setting changes. |
Constructors
BinaryPowerTabPage
Creates a page with no caption, a window-coloured background and a one-pixel border, its header enabled and showing a close button.
BinaryPowerTabPage
Creates a page with the given caption, its header enabled and showing a close button.
Parameters
tabPageText- The header caption (
Text).
Remarks
Unlike the parameterless constructor, this leaves Control.BackColor at the
panel default and BorderSize at 0. To get those defaults with a caption, use new
BinaryPowerTabPage { Text = "Orders" }.
Properties
BorderSize
Gets or sets the width of the border the page draws round its content area, in
BinaryExtendedPanel.BorderColor.
- Value
- The width in pixels. Negative values are stored as 0. The default is 1, or 0 for a page made
with the
BinaryPowerTabPage()constructor.
Remarks
Setting it also sets Control.Padding to the same width (at least 1), so
docked controls sit inside the border.
CurrentlySelected
Gets or sets a flag the strip keeps in step with the selection: true while this is
the selected tab.
- Value
- The default is
false. - Default
false
Remarks
Setting it does not select or deselect the tab; use
BinaryPowerTabStrip.SelectedTabPage, which is also the reliable way to ask which tab
is selected.
CustomEndColor
Gets or sets the colour this header's fill ends at in the RenderingStyle.Custom and
RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Color.Empty: the strip'sBinaryPowerTabStrip.CustomEndColor.
CustomStartColor
Gets or sets the colour this header's fill starts from in the RenderingStyle.Custom
and RenderingStyle.TrapeziumTop styles.
- Value
- The default is
Color.Empty: the strip'sBinaryPowerTabStrip.CustomStartColor.
Remarks
Use it with CustomEndColor to colour-code tabs – one colour per customer,
project or environment. While the tab is selected it is filled with the strip's selection colours
instead, if BinaryPowerTabStrip.UseTabCurrentSelectionIndicatorColor is on.
Example
tabs.TabRenderingStyle = RenderingStyle.Custom;
productionPage.CustomStartColor = Color.MistyRose;
productionPage.CustomEndColor = Color.White;DisabledImage
Gets or sets the picture drawn in place of Image while this tab's header is disabled.
- Value
- The default is
null: a grey copy ofImageis made each time the header is drawn. - Default
null
See also
HeaderTextFont
Gets or sets the font of this tab's header text.
- Value
- The default is the system's default user-interface font. Must not be
null.
Remarks
The strip gives every page its BinaryPowerTabStrip.HeaderFont when the page
joins it and whenever that is set, replacing this value; set a page's own font after those. Setting
it does not lay the headers out again; call BinaryPowerTabStrip.RefreshLayout. The
selected tab may be drawn in BinaryPowerTabStrip.SelectedTabPageHeaderFont
instead.
Image
Gets or sets the picture drawn before the caption in this tab's header.
- Value
- The default is
null: no picture. - Default
null
Remarks
The image is drawn at its own size, in pixels, and the headers are made tall enough for the
tallest image. It is also shown beside the tab's entry in the overflow menu, unless
OverflowMenuImage is set. While the header is disabled, DisabledImage or
a grey copy is drawn instead.
The page disposes this image when it is disposed, so give each page an image of its own rather than one shared with other pages or controls.
IsBackgroundTransparent
Gets or sets whether the page's background is transparent, so whatever is behind the strip shows through.
- Value
- The default is
false.
Remarks
Turning it on sets Control.BackColor to Color.Transparent;
turning it off sets it to SystemColors.Window, whatever it was before. The strip's own
BinaryPowerTabStrip.IsBackgroundTransparent sets this on every page it
holds.
IsHeaderEnabled
Gets or sets whether this tab's header can be clicked.
- Value
- The default is
true.
Remarks
A disabled header is drawn with grey text (unless it is the selected tab) and a grey image
(DisabledImage), has no close button, ignores clicks and double-clicks, and is left
out of the overflow menu. The page can still be selected from code through
BinaryPowerTabStrip.SelectedTabPage.
Example
// The "Approvals" tab is available to managers only.
approvalsPage.IsHeaderEnabled = currentUser.IsManager;ShouldRenderCloseButton
Gets or sets whether this tab's header shows a close button.
- Value
- The default is
true.
Remarks
The button is drawn only while the strip's
BinaryPowerTabStrip.EnableTabPageLevelCloseButtonRendering and this page's
IsHeaderEnabled are on. Turn it off for tabs that must stay open.
Size
Gets or sets the size of the page. The strip sizes its pages to fill the page area, so this is hidden from the designer and the editor's completion lists.
TabPageContentIsDirty
Gets or sets whether the page holds changes the user has not saved – a flag for your own code.
- Value
- The default is
false.
Remarks
The strip does not read or change it. Set it as the page's data changes, and check it in
BinaryPowerTabStrip.TabPageClosing to ask before a tab with unsaved work is
closed.
TabPageHeaderForeColor
Gets or sets the colour of this tab's header text.
- Value
- The default is
Color.Empty: the strip'sBinaryPowerTabStrip.TabPageHeaderForeColor.
Remarks
A disabled header (IsHeaderEnabled) that is not selected is drawn in
SystemColors.GrayText regardless.
TabPageSideBarFillColor
Gets or sets the colour of this header's side bar, when the strip draws side bars.
- Value
- The default is
Color.Empty: the strip'sBinaryPowerTabStrip.TabPageSideBarFillColor.
Remarks
Side bars are drawn while the strip's
BinaryPowerTabStrip.TabPageHeaderShowsSideBar is on, in the
RenderingStyle.Custom style.
Text
Gets or sets the caption shown in this tab's header and in the overflow menu.
- Value
- The default is an empty string.
- Default
Name
Remarks
Setting it repaints the strip, unless the strip's
BinaryPowerTabStrip.PreventInvalidation is on. A caption wider than the strip's
BinaryPowerTabStrip.TabPageHeaderWidth is shortened with an ellipsis.
ToolTipText
Gets or sets the tooltip shown when the pointer rests on this tab's header.
- Value
- The default is an empty string, which shows no tooltip.
Remarks
Shown while the strip's BinaryPowerTabStrip.ShowToolTip is on, styled by its
BinaryPowerTabStrip.ToolTipConfiguration.
Visible
Gets or sets whether this tab is on the strip at all – its header drawn and listed in the overflow menu.
- Value
- The default is
true. - Default
true
Remarks
This is not Visible: the strip shows and hides the page itself as the
selection changes. Setting this to false takes the tab off the strip without
removing the page from BinaryPowerTabStrip.TabPages, and raises
TabPageChanged.
Selecting a hidden page through BinaryPowerTabStrip.SelectedTabPage makes it
visible again.
Methods
Dispose
Releases the page's resources, including its Image.
Parameters
disposingtruewhen called fromDispose;falsefrom the finalizer.
Remarks
DisabledImage and OverflowMenuImage are not disposed.
OnPaint
Draws the page's border (BorderSize, BinaryExtendedPanel.BorderColor),
then raises the Control.Paint event.
Parameters
e- The event data.
OnParentChanged
Raises the Control.ParentChanged event, and takes the new strip's
BinaryPowerTabStrip.HeaderFont as HeaderTextFont.
Parameters
e- The event data.
Exceptions
System.InvalidCastException- The new parent is not a
BinaryPowerTabStrip.
ShouldSerializeControls
Tells the designer to write the page's child controls into the designer file when it has any.
ShouldSerializeDock
Tells the designer not to write Control.Dock into the designer file: the strip docks
its pages itself. Always returns false.
ShouldSerializeIsPaintingComplete
Part of the designer's serialisation support; not for use from application code. Always returns
false.
ShouldSerializeVisible
Tells the designer always to write Visible into the designer file. Always returns
true.
Events
TabPageChanged
Occurs when the page's Visible setting changes.
Remarks
The strip's collection listens for it, lays the headers out again and raises
BinaryPowerTabStrip.TabPageSelectionChanged with
TabPageChangeTriggerSource.Changed.