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 a new instance of the TabStrip class.

public TabStrip()

Remarks

The default constructor initializes all fields to their default values.

Properties

AutoInternalDragDrop

Gets or sets 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

Gets or sets 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

Gets or sets 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

Gets or sets the Sides that the border appears on.

public Sides BorderSides { get; set; }

Property Value

Sides:

The Sides that the border appears on.

Remarks

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

CloseButtonVisible

Gets or sets whether a close button is visible.

public bool CloseButtonVisible { get; set; }

Property Value

bool:

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

CloseCommand

Gets the Command that is used for a close button click.

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

Property Value

Command:

The Command that is used for a close button click.

Gets a CommandLinkCollection containing the command links associated with the object.

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

Property Value

CommandLinkCollection:

A CommandLinkCollection containing the command links associated with the object.

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 display area of the control.

public override Rectangle DisplayRectangle { get; }

Property Value

Rectangle:

A Rectangle that represents the display area of the control.

ForceUnselectedFont

Gets or sets 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

Gets or sets the ICommandTarget to forward commands to.

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

Property Value

ICommandTarget:

The ICommandTarget to forward commands to.

ImageList

Gets or sets the ImageList used for page images.

public ImageList ImageList { get; set; }

Property Value

ImageList:

An ImageList. The default value is null.

KeyboardNavigationEnabled

Gets or sets 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

Gets or sets the maximum extent of a tab.

public int MaximumTabExtent { get; set; }

Property Value

int:

The maximum extent of a tab.

Remarks

Specify -1 to apply no maximum extent.

MinimumTabExtent

Gets or sets the minimum extent of a tab.

public int MinimumTabExtent { get; set; }

Property Value

int:

The minimum extent of a tab.

Remarks

Specify -1 to apply no minimum extent.

OptionsButtonVisible

Gets or sets whether a options button is visible.

public bool OptionsButtonVisible { get; set; }

Property Value

bool:

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

OptionsCommand

Gets the Command that is used for a options button click.

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

Property Value

Command:

The Command that is used for a options button click.

Orientation

Gets the orientation of the tabs in the control.

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

Property Value

Orientation:

A Orientation that specifies the orientation.

PageValidationEnabled

Gets or sets 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

Gets the TabStripPageCollection containing the pages in the control.

public TabStripPageCollection Pages { get; }

Property Value

TabStripPageCollection:

The TabStripPageCollection containing the pages in the control.

Renderer

Gets or sets the control-specific ITabStripRenderer used to render the control.

public ITabStripRenderer Renderer { get; set; }

Property Value

ITabStripRenderer:

The control-specific ITabStripRenderer used to render the control.

Remarks

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

RendererResolved

Gets the ITabStripRenderer used to render the control.

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

Property Value

ITabStripRenderer:

The ITabStripRenderer used to render the control.

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

Gets or sets 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

Gets the Command that is used for a scroll backward button click.

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

Property Value

Command:

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

ScrollDelta

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

public int ScrollDelta { get; set; }

Property Value

int:

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

Remarks

A higher number will scroll faster than a lower number.

ScrollForwardCommand

Gets the Command that is used for a scroll forward button click.

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

Property Value

Command:

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

SelectedIndex

Gets or sets the index of the selected item.

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

Property Value

int:

The index of the selected item. If there are no items in the control, this property returns -1.

Remarks

The index is zero-based.

SelectedPage

Gets or sets the TabStripPage that is currently selected.

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

Property Value

TabStripPage:

The TabStripPage that is currently selected.

SingleTabVisible

Gets or sets whether a tab should still be visible if there is only one TabStripPage in the TabStrip.

public bool SingleTabVisible { get; set; }

Property Value

bool:

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

TabAlignment

Gets or sets a TabStripTabAlignment specifying the alignment of the tabs.

public TabStripTabAlignment TabAlignment { get; set; }

Property Value

TabStripTabAlignment:

A TabStripTabAlignment specifying the alignment of the tabs.

TabAscent

Gets the ascent of a tab.

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

Property Value

int:

The ascent of a tab.

TabOverflowStyle

Gets or sets a TabStripTabOverflowStyle specifying how to handle tab overflow.

public TabStripTabOverflowStyle TabOverflowStyle { get; set; }

Property Value

TabStripTabOverflowStyle:

A TabStripTabOverflowStyle specifying how to handle tab overflow.

TabsAlignNear

Gets or sets 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 on each visible child element and position each child element. It is required that a parent element calls Arrange on each child or they won't be rendered.

CreateChildren()

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

protected override IList CreateChildren()

Returns

IList:

The IList 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 a Control.ControlCollection assigned to the control.

Dispose(bool)

Disposes any resources used by the object.

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

Whether the object is being disposed.

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:

The TabStripButton for the specified Command if the button exists and is visible; otherwise, null is returned.

GetSidesFromTabStripTabAlignment(TabStripTabAlignment)

Gets 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:

The Sides value that corresponds to the specified TabStripTabAlignment.

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:

A TabStripPage whose tab contains the Point.

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

A CommandEventArgs that contains the event data.

OnDragLeave(EventArgs)

Raises the DragOver 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

A DragEventArgs that contains the event data.

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)

Occurs when the mouse leaves the control.

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

An EventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Occurs when the mouse moves.

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

A MouseEventArgs that contains the event data.

OnMouseUp(MouseEventArgs)

Occurs when a mouse button is released.

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

A PaintEventArgs that contains the event data.

OnReselect(TabStripPageEventArgs)

Raises the Reselect event.

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

A TabStripPageEventArgs that contains the event data.

OnSelectionChanged(TabStripPageEventArgs)

Raises the SelectionChanged event.

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

A TabStripPageEventArgs that contains the event data.

OnSelectionChanging(TabStripPageCancelEventArgs)

Raises the SelectionChanging event.

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

A TabStripPageCancelEventArgs that contains the event data.

OnTabStripPageTabContextMenu(TabStripPageContextMenuEventArgs)

Raises the TabStripPageTabContextMenu event.

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

A TabStripPageContextMenuEventArgs that contains the event data.

OnTabStripPageTabDoubleClick(TabStripPageEventArgs)

Raises the TabStripPageTabDoubleClick event.

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

A TabStripPageEventArgs that contains the event data.

OnTabStripPageTabDragStart(TabStripPageEventArgs)

Raises the TabStripPageTabDragStart event.

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

A TabStripPageEventArgs that contains the event data.

OnTabStripPageTabMoved(TabStripPageEventArgs)

Raises the TabStripPageTabMoved event.

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

A TabStripPageEventArgs that contains the event data.

OnTabStripPageTabToolTipDisplaying(TabStripPageEventArgs)

Raises the TabStripPageTabToolTipDisplaying event.

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

A TabStripPageEventArgs that contains the event data.

ProcessCmdKey(ref Message, Keys)

Processes a key.

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

The message to process.

keyData Keys

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

Returns

bool:

true if the key 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