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
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
CommandLinks
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.
DisplayRectangle
Gets the rectangle that represents the display area of the control.
public override Rectangle DisplayRectangle { get; }
Property Value
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
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 isnull
.
KeyboardNavigationEnabled
Gets or sets whether Ctrl+Tab
keyboard navigation is enabled for switching between pages.
public bool KeyboardNavigationEnabled { get; set; }
Property Value
- bool:
true
ifCtrl+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
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
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
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.
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
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 |
OnDragLeave(EventArgs)
Raises the DragOver
event.
protected override void OnDragLeave(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnDragOver(DragEventArgs)
Raises the DragOver
event.
protected override void OnDragOver(DragEventArgs e)
Parameter | Type | Description |
---|---|---|
e | DragEventArgs | A |
OnEnter(EventArgs)
Raises the Enter event.
protected override void OnEnter(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnLeave(EventArgs)
Raises the Leave event.
protected override void OnLeave(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnMouseLeave(EventArgs)
Occurs when the mouse leaves the control.
protected override void OnMouseLeave(EventArgs e)
Parameter | Type | Description |
---|---|---|
e | EventArgs | An |
OnMouseMove(MouseEventArgs)
Occurs when the mouse moves.
protected override void OnMouseMove(MouseEventArgs e)
Parameter | Type | Description |
---|---|---|
e | MouseEventArgs | A |
OnMouseUp(MouseEventArgs)
Occurs when a mouse button is released.
protected override void OnMouseUp(MouseEventArgs e)
Parameter | Type | Description |
---|---|---|
e | MouseEventArgs | A |
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 |
OnSelectionChanged(TabStripPageEventArgs)
Raises the SelectionChanged
event.
protected virtual void OnSelectionChanged(TabStripPageEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageEventArgs | A |
OnSelectionChanging(TabStripPageCancelEventArgs)
Raises the SelectionChanging
event.
protected virtual void OnSelectionChanging(TabStripPageCancelEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageCancelEventArgs | A |
OnTabStripPageTabContextMenu(TabStripPageContextMenuEventArgs)
Raises the TabStripPageTabContextMenu
event.
protected virtual void OnTabStripPageTabContextMenu(TabStripPageContextMenuEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageContextMenuEventArgs | A |
OnTabStripPageTabDoubleClick(TabStripPageEventArgs)
Raises the TabStripPageTabDoubleClick
event.
protected virtual void OnTabStripPageTabDoubleClick(TabStripPageEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageEventArgs | A |
OnTabStripPageTabDragStart(TabStripPageEventArgs)
Raises the TabStripPageTabDragStart
event.
protected virtual void OnTabStripPageTabDragStart(TabStripPageEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageEventArgs | A |
OnTabStripPageTabMoved(TabStripPageEventArgs)
Raises the TabStripPageTabMoved
event.
protected virtual void OnTabStripPageTabMoved(TabStripPageEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageEventArgs | A |
OnTabStripPageTabToolTipDisplaying(TabStripPageEventArgs)
Raises the TabStripPageTabToolTipDisplaying
event.
protected virtual void OnTabStripPageTabToolTipDisplaying(TabStripPageEventArgs e)
Parameter | Type | Description |
---|---|---|
e | TabStripPageEventArgs | A |
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 |
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
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
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
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
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
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
TabStripPageTabDoubleClick
Occurs when a tab is double-clicked.
public event TabStripPageEventHandler TabStripPageTabDoubleClick
Event Type
TabStripPageTabDragStart
Occurs when a tab is starting to be dragged.
TabStripPageTabMoved
Occurs after a tab drag is moved via end user dragging when AutoInternalDragDrop is true
.
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
Inherited Members
- UIControl.AddPendingGraphicsInversion(Rectangle)
- UIControl.AddPendingScrollOperation(Rectangle, Orientation, int)
- UIControl.AddPendingScrollOperation(Rectangle, int, int)
- UIControl.AddToInvalidatedRegion()
- UIControl.AddToInvalidatedRegion(Rectangle)
- UIControl.Arrange(Rectangle)
- UIControl.ContainsLocation(Point)
- UIControl.DpiScaleChanged(SizeF)
- UIControl.GetCursor(Point)
- UIControl.Invalidate(InvalidationLevels, InvalidationTypes)
- UIControl.InvalidateArrange()
- UIControl.InvalidateMeasure()
- UIControl.Measure(Graphics, Size)
- UIControl.OnClick(EventArgs)
- UIControl.OnDoubleClick(EventArgs)
- UIControl.OnDpiChangedAfterParent(EventArgs)
- UIControl.OnHandleCreated(EventArgs)
- UIControl.OnLayout(LayoutEventArgs)
- UIControl.OnLocationChanged(EventArgs)
- UIControl.OnMouseCaptureChanged(EventArgs)
- UIControl.OnMouseDown(MouseEventArgs)
- UIControl.OnMouseEnter(EventArgs)
- UIControl.OnMouseHover(EventArgs)
- UIControl.OnMouseWheel(MouseEventArgs)
- UIControl.OnPaint(PaintEventArgs)
- UIControl.OnPaintBackground(PaintEventArgs)
- UIControl.OnParentChanged()
- UIControl.OnParentChanged(EventArgs)
- UIControl.OnRenderChildElements(PaintEventArgs)
- UIControl.OnResize(EventArgs)
- UIControl.OnRightToLeftChanged(EventArgs)
- UIControl.OnVisibleChanged(EventArgs)
- UIControl.Render(PaintEventArgs)
- UIControl.ResetDoubleBufferCanvas(bool)
- UIControl.ResumePainting()
- UIControl.SuspendPainting()
- UIControl.TransformToAncestor(IUIElement)
- UIControl.TransformToDescendant(IUIElement)
- UIControl.UpdateCursor()
- UIControl.UpdateLayout()
- UIControl.ActualHeight
- UIControl.ActualWidth
- UIControl.BackColor
- UIControl.BackgroundImage
- UIControl.CaptureMouseWhenPressed
- UIControl.ClipBounds
- UIControl.DesiredSize
- UIControl.DpiScaleFactor
- UIControl.Font
- UIControl.ForeColor
- UIControl.IsArrangeValid
- UIControl.IsMeasureValid
- UIControl.IsPaintValid
- UIControl.IsRightToLeft
- UIControl.LastMouseUpButton
- UIControl.PaintingSuspended
- UIControl.UseControlGraphicsForMeasure
- UIControl.UseExtendedDoubleBuffering
- MarshalByRefObject.GetLifetimeService()
- MarshalByRefObject.InitializeLifetimeService()
- MarshalByRefObject.MemberwiseClone(bool)
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()