Skip to content

TabControl Class

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

C#
public class TabControl : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable

Inheritance objectControlBaseCompositeControl

Implements IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable

TabControl(IEnumerable<TabItem>, int, int)

Section titled “TabControl(IEnumerable<TabItem>, int, int)”

Creates a new tab control with the specified tab items.

C#
public TabControl(IEnumerable<TabItem> tabItems, int width, int height)

tabItems IEnumerable<TabItem>
Tabs that are present on the tabcontrol

width int
Width of the content area

height int
Heigh of the content area

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

Section titled “TabControl(IEnumerable<TabItem>, int, int, int)”

Creates a new tab control with the specified tab items.

C#
public TabControl(IEnumerable<TabItem> tabItems, int activeTabIndex, int width, int height)

tabItems IEnumerable<TabItem>
Tabs that are present on the tabcontrol

activeTabIndex int
What tab to be active on initialization

width int
Width of the content area

height int
Heigh of the content area

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

C#
public const int InvalidActiveTabIndex = -1

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

C#
protected Point CachedMousePosition

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

C#
protected Rectangle ContentRegion

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

C#
protected Rectangle TabsRegion

The list of tab items displayed by the control.

C#
[DataMember]
protected List<TabItem> TabItems { get; set; }

Gets a list of tabs in this control.

C#
public ListEnumerator<TabItem> Tabs { get; }

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

C#
[DataMember]
public int ActiveTabIndex { get; protected set; }

Retursn the current tab.

C#
public TabItem CurrentTab { get; }

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

C#
[DataMember]
public TabControl.Orientation TabOrientation { get; set; }

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

C#
[DataMember]
public int[] ConnectedLineStyle { get; set; }

Gets or sets the tab item at the specified index.

C#
public TabItem this[int index] { get; set; }

Adds a tab to the control.

C#
public void AddTab(TabItem tab)

tab TabItem
TabItem with header and associated console for tab content

Creates and adds a tab to the control.

C#
public TabItem AddTab(string header, Panel content)

header string
The header of the new tab.

content Panel
Associated content for the new tab.

TabItem
The new tab item.

Removes a tab from the control.

C#
public void RemoveTab(TabItem tab)

tab TabItem
TabItem that should be removed

Removes a tab by index.

C#
public void RemoveTab(int index)

index int
The index of the tab to remove.

Sets the tab specified by the index as active.

C#
public void SetActiveTab(int index)

index int
Index of the tab.

Raises the ActiveTabItemChanged event.

C#
protected void OnActiveTabItem(int previousActiveIndex, int activeIndex)

previousActiveIndex int
The tab index of the previous item.

activeIndex int
The index of the active tab.

Gets the index of a tab

C#
public int GetTabIndex(TabItem tab)

tab TabItem
Tab you need the index of

int
0 based index of the tab

Determines whether a tab is contained in this control.

C#
public bool ContainsTab(TabItem tab)

tab TabItem
The tab to check.

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

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

C#
public bool SelectNextTab()

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

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

C#
public bool SelectPreviousTab()

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

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

C#
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

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

C#
protected override void OnMouseIn(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Resizes the tab item.

C#
protected override void OnResized()

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

C#
protected void ThemeDetermineContentRegion()

Updates each control hosted by this control.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The game frame time delta.

Raised when the active tab changes.

C#
public event EventHandler<ValueChangedEventArgs<TabItem?>>? ActiveTabItemChanged

EventHandler<ValueChangedEventArgs<TabItem>>