In This Article

TabStrip Class

Represents a tabstrip control.

[ToolboxBitmap(typeof(TabStrip))]
public class TabStrip : UIControl, IUIControl, IUIElement, ILogicalTreeNode, IDpiAwareElement, IDisposable, ICommandTarget, IWeakEventListener, IOrientedElement
Inheritance:
object MarshalByRefObject Component Control ScrollableControl UIControl object
Implements:
IUIControl IUIElement ILogicalTreeNode IDpiAwareElement IDisposable ICommandTarget IWeakEventListener IOrientedElement

Constructors

TabStrip()

Initializes an instance of the class.

public TabStrip()

Properties

AutoInternalDragDrop

Indicates whether to automatically allow internal drag/drop reordering of tabs.

public bool AutoInternalDragDrop { get; set; }

Property Value

bool:

true if automatic internal reordering of tabs is allowed; otherwise, false.

Remarks

If this property is set to true, no TabStripPageTabDragStart event is raised when a drag begins since all drag-handling code is handled internally by the control.

AutoSelectTabOnDragOver

Indicates whether to automatically select a page when a drag operation is moved over the page's tab.

public bool AutoSelectTabOnDragOver { get; set; }

Property Value

bool:

true if a page should be automatically selected when a drag operation is moved over the page's tab; otherwise, false.

AutoSetFocusOnClick

Indicates whether to automatically set focus to the page when a page's tab is clicked.

public bool AutoSetFocusOnClick { get; set; }

Property Value

bool:

true if focus should be set when a page's tab is clicked; otherwise, false.

BorderSides

The Sides that the border appears on.

public Sides BorderSides { get; set; }

Property Value

Sides

Remarks

This is used with the renderer's TabStripPageMargin to know which sides to indent client bounds.

CloseButtonVisible

Indicates whether a close button is visible.

public bool CloseButtonVisible { get; set; }

Property Value

bool:

true if a close button is visible; otherwise, false.

CloseCommand

The Command that is used for a close button click.

[Browsable(false)]
public static Command CloseCommand { get; }

Property Value

Command

A CommandLinkCollection containing the command links associated with the object.

[Browsable(false)]
public CommandLinkCollection CommandLinks { get; }

Property Value

CommandLinkCollection

DefaultSize

Gets the default size of the control.

protected override Size DefaultSize { get; }

Property Value

Size:

The default Size of the control.

DisplayRectangle

Gets the rectangle that represents the virtual display area of the control.

public override Rectangle DisplayRectangle { get; }

Property Value

Rectangle:

A Rectangle that represents the display area of the control.

ForceUnselectedFont

Indicates whether to force the control to tab text using the unselected Font, even for selected tabs.

public bool ForceUnselectedFont { get; set; }

Property Value

bool:

true if the unselected Font should always be used; otherwise, false.

ForwardCommandsTo

The ICommandTarget, if any, to forward commands to.

[Browsable(false)]
public ICommandTarget? ForwardCommandsTo { get; set; }

Property Value

ICommandTarget

ImageList

The ImageList used for page images.

public ImageList? ImageList { get; set; }

Property Value

ImageList:

The default value is null.

KeyboardNavigationEnabled

Indicates whether Ctrl+Tab keyboard navigation is enabled for switching between pages.

public bool KeyboardNavigationEnabled { get; set; }

Property Value

bool:

true if Ctrl+Tab keyboard navigation is enabled for switching between pages; otherwise, false.

Remarks

If keyboard navigation is enabled, the Ctrl+Tab and Ctrl+Shift+Tab keys will switch between pages.

MaximumTabExtent

The maximum extent of a tab.

public int MaximumTabExtent { get; set; }

Property Value

int

Remarks

Specify -1 to apply no maximum extent.

MinimumTabExtent

The minimum extent of a tab.

public int MinimumTabExtent { get; set; }

Property Value

int

Remarks

Specify -1 to apply no minimum extent.

OptionsButtonVisible

Indicates whether an options button is visible.

public bool OptionsButtonVisible { get; set; }

Property Value

bool:

true if an options button is visible; otherwise, false.

OptionsCommand

The Command that is used for a options button click.

[Browsable(false)]
public static Command OptionsCommand { get; }

Property Value

Command

Orientation

The orientation of the tabs in the control.

[Browsable(false)]
public Orientation Orientation { get; }

Property Value

Orientation

PageValidationEnabled

Indicates whether the SelectedPage is validated before allowing a page change to occur.

public bool PageValidationEnabled { get; set; }

Property Value

bool:

true if the SelectedPage is validated before allowing a page change to occur; otherwise, false.

Pages

The TabStripPageCollection containing the pages in the control.

public TabStripPageCollection Pages { get; }

Property Value

TabStripPageCollection

Renderer

The control-specific ITabStripRenderer used to render the control.

public ITabStripRenderer? Renderer { get; set; }

Property Value

ITabStripRenderer

Remarks

If this value is null, then the global renderer will be used instead.

RendererResolved

The ITabStripRenderer used to render the control.

[Browsable(false)]
public ITabStripRenderer RendererResolved { get; }

Property Value

ITabStripRenderer

Remarks

This property will return a global renderer if there is no control instance renderer override. The registered renderer type with the UIRendererManager for this property is ITabStripRenderer.

RightClickSelectsTab

Indicates whether a right-click on a tab selects the related page.

public bool RightClickSelectsTab { get; set; }

Property Value

bool:

true if a right-click on a tab selects the related page; otherwise, false.

ScrollBackwardCommand

The Command that is used for a scroll backward button click.

[Browsable(false)]
public static Command ScrollBackwardCommand { get; }

Property Value

Command

ScrollDelta

The number of pixels to scroll per step when a scroll button is pressed.

public int ScrollDelta { get; set; }

Property Value

int

Remarks

A higher number will scroll faster than a lower number.

ScrollForwardCommand

The Command that is used for a scroll forward button click.

[Browsable(false)]
public static Command ScrollForwardCommand { get; }

Property Value

Command

SelectedIndex

The index of the selected item.

[Browsable(false)]
public int SelectedIndex { get; set; }

Property Value

int:

If there are no items in the control, this property returns -1.

Remarks

The index is zero-based.

SelectedPage

The TabStripPage that is currently selected.

[Browsable(false)]
public TabStripPage? SelectedPage { get; set; }

Property Value

TabStripPage

SingleTabVisible

Indicates whether a tab should still be visible if there is only one TabStripPage in the tab strip.

public bool SingleTabVisible { get; set; }

Property Value

bool:

true if the tab should be visible; otherwise, false.

TabAlignment

A TabStripTabAlignment specifying the alignment of the tabs.

public TabStripTabAlignment TabAlignment { get; set; }

Property Value

TabStripTabAlignment

TabAscent

The ascent of a tab.

[Browsable(false)]
public int TabAscent { get; }

Property Value

int

TabOverflowStyle

A TabStripTabOverflowStyle specifying how to handle tab overflow.

public TabStripTabOverflowStyle TabOverflowStyle { get; set; }

Property Value

TabStripTabOverflowStyle

TabsAlignNear

Indicates whether the tabs should align on the near side (left, top) of the tab container or on the far side (right, bottom).

public bool TabsAlignNear { get; set; }

Property Value

bool:

true if the tabs should align on the near side of the tab container; otherwise, false.

Methods

ArrangeOverride(Size)

Positions child elements and determines an arrange size.

protected override Size ArrangeOverride(Size finalSize)
Parameter Type Description
finalSize Size

The final area within the parent that this element should use to arrange itself and its children.

Returns

Size:

The actual size used.

Remarks

Element authors should override this method, call Arrange(Rectangle) on each visible child element and position each child element. It is required that a parent element calls Arrange(Rectangle) on each child or they won't be rendered.

CreateChildren()

Invoked when the collection of child elements is to be created.

protected override IList<ILogicalTreeNode> CreateChildren()

Returns

IList<ILogicalTreeNode>:

The list that should be assigned to the Children property.

Remarks

By default, no child collection is created.

CreateControlsInstance()

Creates a new instance of the control collection for the control.

protected override Control.ControlCollection CreateControlsInstance()

Returns

Control.ControlCollection:

A new instance of Control.ControlCollection assigned to the control.

Dispose(bool)

Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

protected override void Dispose(bool disposing)
Parameter Type Description
disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetButtonForCommand(Command)

Returns the TabStripButton for the specified Command.

public TabStripButton? GetButtonForCommand(Command command)
Parameter Type Description
command Command

The Command to search for.

Returns

TabStripButton

GetSidesFromTabStripTabAlignment(TabStripTabAlignment)

The Sides value that corresponds to the specified TabStripTabAlignment.

public static Sides GetSidesFromTabStripTabAlignment(TabStripTabAlignment tabAlignment)
Parameter Type Description
tabAlignment TabStripTabAlignment

The TabStripTabAlignment to examine.

Returns

Sides

HitTest(Point)

Hit tests to find the TabStripPage whose tab contains the specified coordinates.

public TabStripPage? HitTest(Point point)
Parameter Type Description
point Point

The Point to test.

Returns

TabStripPage

MeasureOverride(Graphics?, Size)

Measures the size in layout required for child elements and determines a size for the element itself.

protected override Size MeasureOverride(Graphics? g, Size availableSize)
Parameter Type Description
g Graphics

The Graphics object to use for measurement.

availableSize Size

The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.

Returns

Size:

The size that this element determines it needs during layout, based on its calculations of child element sizes.

Remarks

Element authors should override this method, call Measure(Graphics?, Size) on each visible child element and determine the total size required.

OnCommand(CommandEventArgs)

Raises the Command event.

protected virtual void OnCommand(CommandEventArgs e)
Parameter Type Description
e CommandEventArgs

The event data.

OnDragLeave(EventArgs)

Raises the DragLeave event.

protected override void OnDragLeave(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnDragOver(DragEventArgs)

Raises the DragOver event.

protected override void OnDragOver(DragEventArgs e)
Parameter Type Description
e DragEventArgs

OnEnter(EventArgs)

Raises the Enter event.

protected override void OnEnter(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnLeave(EventArgs)

Raises the Leave event.

protected override void OnLeave(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnMouseLeave(EventArgs)

Raises the MouseLeave event.

protected override void OnMouseLeave(EventArgs e)
Parameter Type Description
e EventArgs

An EventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Raises the MouseMove event.

protected override void OnMouseMove(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseUp(MouseEventArgs)

Raises the MouseUp event.

protected override void OnMouseUp(MouseEventArgs e)
Parameter Type Description
e MouseEventArgs

A MouseEventArgs that contains the event data.

OnRender(PaintEventArgs)

Renders the element.

protected override void OnRender(PaintEventArgs e)
Parameter Type Description
e PaintEventArgs

The event data.

OnReselect(TabStripPageEventArgs)

Raises the Reselect event.

protected virtual void OnReselect(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

OnSelectionChanged(TabStripPageEventArgs)

Raises the SelectionChanged event.

protected virtual void OnSelectionChanged(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

OnSelectionChanging(TabStripPageCancelEventArgs)

Raises the SelectionChanging event.

protected virtual void OnSelectionChanging(TabStripPageCancelEventArgs e)
Parameter Type Description
e TabStripPageCancelEventArgs

The event data.

OnTabStripPageTabContextMenu(TabStripPageContextMenuEventArgs)

Raises the TabStripPageTabContextMenu event.

protected virtual void OnTabStripPageTabContextMenu(TabStripPageContextMenuEventArgs e)
Parameter Type Description
e TabStripPageContextMenuEventArgs

The event data.

OnTabStripPageTabDoubleClick(TabStripPageEventArgs)

Raises the TabStripPageTabDoubleClick event.

protected virtual void OnTabStripPageTabDoubleClick(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

OnTabStripPageTabDragStart(TabStripPageEventArgs)

Raises the TabStripPageTabDragStart event.

protected virtual void OnTabStripPageTabDragStart(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

OnTabStripPageTabMoved(TabStripPageEventArgs)

Raises the TabStripPageTabMoved event.

protected virtual void OnTabStripPageTabMoved(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

OnTabStripPageTabToolTipDisplaying(TabStripPageEventArgs)

protected virtual void OnTabStripPageTabToolTipDisplaying(TabStripPageEventArgs e)
Parameter Type Description
e TabStripPageEventArgs

The event data.

ProcessCmdKey(ref Message, Keys)

Processes a command key.

protected override bool ProcessCmdKey(ref Message m, Keys keyData)
Parameter Type Description
m Message
keyData Keys

One of the Keys values that represents the key to process.

Returns

bool:

true if the character was processed by the control; otherwise, false.

RaiseCommand(Command)

Raises the specified Command.

public virtual bool RaiseCommand(Command command)
Parameter Type Description
command Command

The Command to raise.

Returns

bool:

true if the Command was handled; otherwise, false.

ResetImageList()

Resets the ImageList property to its default value.

public virtual void ResetImageList()

SelectNext()

Selects the next TabStripPage, wrapping to the beginning if necessary.

public int SelectNext()

Returns

int:

The index of the new selected TabStripPage.

Remarks

If the last TabStripPage is selected when this method is called, the control will select the first TabStripPage.

SelectNext(bool)

Selects the next TabStripPage, optionally wrapping to the beginning if necessary.

public int SelectNext(bool wrap)
Parameter Type Description
wrap bool

Indicates whether to wrap to the beginning if the last TabStripPage is selected.

Returns

int:

The index of the new selected TabStripPage.

Remarks

If the last TabStripPage is selected when this method is called, the control will select the first TabStripPage if the wrap parameter is set to true.

SelectPrevious()

Selects the previous TabStripPage, wrapping to the end if necessary.

public int SelectPrevious()

Returns

int:

The index of the new selected TabStripPage.

Remarks

If the first TabStripPage is selected when this method is called, the control will select the last TabStripPage.

SelectPrevious(bool)

Selects the previous TabStripPage, optionally wrapping to the end if necessary.

public int SelectPrevious(bool wrap)
Parameter Type Description
wrap bool

Indicates whether to wrap to the end if the first TabStripPage is selected.

Returns

int:

The index of the new selected TabStripPage.

Remarks

If the first TabStripPage is selected when this method is called, the control will select the last TabStripPage if the wrap parameter is set to true.

ShouldSerializeImageList()

Indicates whether the ImageList property should be persisted.

public virtual bool ShouldSerializeImageList()

Returns

bool:

true if the property value has changed from its default; otherwise, false.

Events

Command

Occurs when a Command is executed.

public event CommandEventHandler? Command

Event Type

CommandEventHandler

Remarks

Each TabStripButton in the TabStrip is associated with a Command. Use this event to perform any processing that should occur when a TabStripButton click occurs.

Reselect

Occurs after a TabStripPage is reselected.

public event TabStripPageEventHandler? Reselect

Event Type

TabStripPageEventHandler

Remarks

Use this event to perform any processing that should occur after an TabStripPage is clicked after it has already been selected.

SelectionChanged

Occurs after the selection changes.

public event TabStripPageEventHandler? SelectionChanged

Event Type

TabStripPageEventHandler

Remarks

Use this event to perform any processing that should occur after the selection changes.

SelectionChanging

Occurs before the selection changes.

public event TabStripPageCancelEventHandler? SelectionChanging

Event Type

TabStripPageCancelEventHandler

Remarks

Use this event to perform any processing that should occur before selection changes. The TabStripPage property of the event arguments indicates the TabStripPage about to be selected. The selection change may be cancelled by setting the Cancel property of the event arguments to true.

TabStripPageTabContextMenu

Occurs when a TabStripPage tab needs a context menu displayed.

public event TabStripPageContextMenuEventHandler? TabStripPageTabContextMenu

Event Type

TabStripPageContextMenuEventHandler

TabStripPageTabDoubleClick

Occurs when a tab is double-clicked.

public event TabStripPageEventHandler? TabStripPageTabDoubleClick

Event Type

TabStripPageEventHandler

TabStripPageTabDragStart

Occurs when a tab is starting to be dragged.

public event TabStripPageEventHandler? TabStripPageTabDragStart

Event Type

TabStripPageEventHandler

TabStripPageTabMoved

Occurs after a tab drag is moved via end user dragging when AutoInternalDragDrop is true.

public event TabStripPageEventHandler? TabStripPageTabMoved

Event Type

TabStripPageEventHandler

TabStripPageTabToolTipDisplaying

Occurs before a tool tip is displayed for a tab and gives an opportunity to update the tab's tool tip text.

public event TabStripPageEventHandler? TabStripPageTabToolTipDisplaying

Event Type

TabStripPageEventHandler

Inherited Members

Extension Methods