Show / Hide Table of Contents

Class TabControl

A control with tabs along the edge of the control. Each tab sets the content of the control.

Inheritance
object
ControlBase
CompositeControl
TabControl
Implements
IContainer
IList<ControlBase>
ICollection<ControlBase>
IEnumerable<ControlBase>
IEnumerable
Inherited Members
CompositeControl.MouseLastHandledByChild
CompositeControl.Controls
CompositeControl.NamedControls
CompositeControl.CreateChildControls()
CompositeControl.ProcessMouse(MouseScreenObjectState)
CompositeControl.OnMouseExit(ControlBase.ControlMouseState)
CompositeControl.AddControl(ControlBase)
CompositeControl.RemoveControl(ControlBase)
CompositeControl.Count
ControlBase.MouseState_IsMouseOver
ControlBase.MouseState_EnteredWithButtonDown
ControlBase.MouseState_IsMouseLeftDown
ControlBase.MouseState_IsMouseRightDown
ControlBase.OnUnfocused()
ControlBase.OnFocused()
ControlBase.OnIsDirtyChanged()
ControlBase.ProcessKeyboard(Keyboard)
ControlBase.LostMouse(MouseScreenObjectState)
ControlBase.OnParentChanged()
ControlBase.OnPositionChanged()
ControlBase.PlaceRelativeTo(ControlBase, Direction.Types, int)
ControlBase.DetermineState()
ControlBase.OnStateChanged(ControlStates, ControlStates)
ControlBase.OnSurfaceChanged(ICellSurface, ICellSurface)
ControlBase.FindThemeFont()
ControlBase.FindThemeColors()
ControlBase.SetThemeColors(Colors)
ControlBase.HasThemeColors()
ControlBase.Resize(int, int)
ControlBase.CreateControlSurface()
ControlBase.RefreshThemeStateColors(Colors)
ControlBase.OnMouseEnter(ControlBase.ControlMouseState)
ControlBase.OnRightMouseClicked(ControlBase.ControlMouseState)
ControlBase.ThemeState
ControlBase.UseKeyboard
ControlBase.UseMouse
ControlBase.CanFocus
ControlBase.CanResize
ControlBase.AlternateFont
ControlBase.Surface
ControlBase.MouseArea
ControlBase.IsMouseButtonStateClean
ControlBase.Position
ControlBase.AbsolutePosition
ControlBase.IsVisible
ControlBase.Tag
ControlBase.TabStop
ControlBase.TabIndex
ControlBase.IsDirty
ControlBase.Name
ControlBase.FocusOnMouseClick
ControlBase.Width
ControlBase.Height
ControlBase.IsFocused
ControlBase.IsEnabled
ControlBase.Bounds
ControlBase.Parent
ControlBase.State
ControlBase.IsDirtyChanged
ControlBase.Focused
ControlBase.Unfocused
ControlBase.PositionChanged
ControlBase.MouseEnter
ControlBase.MouseExit
ControlBase.MouseMove
ControlBase.MouseButtonClicked
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
public class TabControl : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable

Constructors

TabControl(IEnumerable<TabItem>, int, int)

Creates a new tab control with the specified tab items.

Declaration
public TabControl(IEnumerable<TabItem> tabItems, int width, int height)
Parameters
Type Name Description
IEnumerable<TabItem> tabItems

Tabs that are present on the tabcontrol

int width

Width of the content area

int height

Heigh of the content area

TabControl(IEnumerable<TabItem>, int, int, int)

Creates a new tab control with the specified tab items.

Declaration
public TabControl(IEnumerable<TabItem> tabItems, int activeTabIndex, int width, int height)
Parameters
Type Name Description
IEnumerable<TabItem> tabItems

Tabs that are present on the tabcontrol

int activeTabIndex

What tab to be active on initialization

int width

Width of the content area

int height

Heigh of the content area

Fields

CachedMousePosition

The mouse position recorded from the last time the mouse was over the control.

Declaration
protected Point CachedMousePosition
Field Value
Type Description
Point

ContentRegion

The region of the control where a tab item's content should be displayed.

Declaration
protected Rectangle ContentRegion
Field Value
Type Description
Rectangle

InvalidActiveTabIndex

The index used when there isn't an active tab.

Declaration
public const int InvalidActiveTabIndex = -1
Field Value
Type Description
int

TabsRegion

The region of the control where a tab headers should be displayed.

Declaration
protected Rectangle TabsRegion
Field Value
Type Description
Rectangle

Properties

ActiveTabIndex

The index of the active tab. If InvalidActiveTabIndex is returned, there is no active tab.

Declaration
[DataMember]
public int ActiveTabIndex { get; protected set; }
Property Value
Type Description
int

ConnectedLineStyle

An array of glyphs indexed by ICellSurface.ConnectedLineIndex. Defaults to ConnectedLineThin.

Declaration
[DataMember]
public int[] ConnectedLineStyle { get; set; }
Property Value
Type Description
int[]

CurrentTab

Retursn the current tab.

Declaration
public TabItem CurrentTab { get; }
Property Value
Type Description
TabItem

this[int]

Gets or sets the tab item at the specified index.

Declaration
public TabItem this[int index] { get; set; }
Parameters
Type Name Description
int index

The index of the tab item to get or set.

Property Value
Type Description
TabItem

The tab item content.

TabItems

The list of tab items displayed by the control.

Declaration
[DataMember]
protected List<TabItem> TabItems { get; set; }
Property Value
Type Description
List<TabItem>

TabOrientation

Sets the position of the tab strip to the top or bottom of the control.

Declaration
[DataMember]
public TabControl.Orientation TabOrientation { get; set; }
Property Value
Type Description
TabControl.Orientation

Tabs

Gets a list of tabs in this control.

Declaration
public ListEnumerator<TabItem> Tabs { get; }
Property Value
Type Description
ListEnumerator<TabItem>

Methods

AddTab(TabItem)

Adds a tab to the control.

Declaration
public void AddTab(TabItem tab)
Parameters
Type Name Description
TabItem tab

TabItem with header and associated console for tab content

AddTab(string, Panel)

Creates and adds a tab to the control.

Declaration
public TabItem AddTab(string header, Panel content)
Parameters
Type Name Description
string header

The header of the new tab.

Panel content

Associated content for the new tab.

Returns
Type Description
TabItem

The new tab item.

ContainsTab(TabItem)

Determines whether a tab is contained in this control.

Declaration
public bool ContainsTab(TabItem tab)
Parameters
Type Name Description
TabItem tab

The tab to check.

Returns
Type Description
bool

Returns true when the tab is in the control; otherwise, false.

GetTabIndex(TabItem)

Gets the index of a tab

Declaration
public int GetTabIndex(TabItem tab)
Parameters
Type Name Description
TabItem tab

Tab you need the index of

Returns
Type Description
int

0 based index of the tab

OnActiveTabItem(int, int)

Raises the ActiveTabItemChanged event.

Declaration
protected void OnActiveTabItem(int previousActiveIndex, int activeIndex)
Parameters
Type Name Description
int previousActiveIndex

The tab index of the previous item.

int activeIndex

The index of the active tab.

OnLeftMouseClicked(ControlMouseState)

Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.

Declaration
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)
Parameters
Type Name Description
ControlBase.ControlMouseState state

The current mouse data

Overrides
ControlBase.OnLeftMouseClicked(ControlBase.ControlMouseState)

OnMouseIn(ControlMouseState)

Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.

Declaration
protected override void OnMouseIn(ControlBase.ControlMouseState state)
Parameters
Type Name Description
ControlBase.ControlMouseState state

The current mouse data

Overrides
ControlBase.OnMouseIn(ControlBase.ControlMouseState)

OnResized()

Resizes the tab item.

Declaration
protected override void OnResized()
Overrides
ControlBase.OnResized()

RemoveTab(TabItem)

Removes a tab from the control.

Declaration
public void RemoveTab(TabItem tab)
Parameters
Type Name Description
TabItem tab

TabItem that should be removed

RemoveTab(int)

Removes a tab by index.

Declaration
public void RemoveTab(int index)
Parameters
Type Name Description
int index

The index of the tab to remove.

SelectNextTab()

Sets the next tab as active. Stops at the last tab.

Declaration
public bool SelectNextTab()
Returns
Type Description
bool

Returns true when the active tab changes; otherwise, false.

SelectPreviousTab()

Sets the previous tab as active. Stops at the first tab.

Declaration
public bool SelectPreviousTab()
Returns
Type Description
bool

Returns true when the active tab changes; otherwise, false.

SetActiveTab(int)

Sets the tab specified by the index as active.

Declaration
public void SetActiveTab(int index)
Parameters
Type Name Description
int index

Index of the tab.

ThemeDetermineContentRegion()

Sets the ContentRegion rectangle to how much space the tab control should give to tab item content.

Declaration
protected void ThemeDetermineContentRegion()

UpdateAndRedraw(TimeSpan)

Updates each control hosted by this control.

Declaration
public override void UpdateAndRedraw(TimeSpan time)
Parameters
Type Name Description
TimeSpan time

The game frame time delta.

Overrides
CompositeControl.UpdateAndRedraw(TimeSpan)

Events

ActiveTabItemChanged

Raised when the active tab changes.

Declaration
public event EventHandler<ValueChangedEventArgs<TabItem?>>? ActiveTabItemChanged
Event Type
Type Description
EventHandler<ValueChangedEventArgs<TabItem>>

Implements

IContainer
IList<T>
ICollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX