TabControl Class
Definition
Section titled “Definition”A control with tabs along the edge of the control. Each tab sets the content of the control.
public class TabControl : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerableInheritance object → ControlBase → CompositeControl
Implements IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable
Constructors
Section titled “Constructors”TabControl(IEnumerable<TabItem>, int, int)
Section titled “TabControl(IEnumerable<TabItem>, int, int)”Creates a new tab control with the specified tab items.
public TabControl(IEnumerable<TabItem> tabItems, int width, int height)Parameters
Section titled “Parameters”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.
public TabControl(IEnumerable<TabItem> tabItems, int activeTabIndex, int width, int height)Parameters
Section titled “Parameters”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
Fields
Section titled “Fields”InvalidActiveTabIndex
Section titled “InvalidActiveTabIndex”The index used when there isn’t an active tab.
public const int InvalidActiveTabIndex = -1CachedMousePosition
Section titled “CachedMousePosition”The mouse position recorded from the last time the mouse was over the control.
protected Point CachedMousePositionContentRegion
Section titled “ContentRegion”The region of the control where a tab item’s content should be displayed.
protected Rectangle ContentRegionTabsRegion
Section titled “TabsRegion”The region of the control where a tab headers should be displayed.
protected Rectangle TabsRegionProperties
Section titled “Properties”TabItems
Section titled “TabItems”The list of tab items displayed by the control.
[DataMember]protected List<TabItem> TabItems { get; set; }Gets a list of tabs in this control.
public ListEnumerator<TabItem> Tabs { get; }ActiveTabIndex
Section titled “ActiveTabIndex”The index of the active tab. If InvalidActiveTabIndex is returned, there is no active tab.
[DataMember]public int ActiveTabIndex { get; protected set; }CurrentTab
Section titled “CurrentTab”Retursn the current tab.
public TabItem CurrentTab { get; }TabOrientation
Section titled “TabOrientation”Sets the position of the tab strip to the top or bottom of the control.
[DataMember]public TabControl.Orientation TabOrientation { get; set; }ConnectedLineStyle
Section titled “ConnectedLineStyle”An array of glyphs indexed by ICellSurface.ConnectedLineIndex. Defaults to ConnectedLineThin.
[DataMember]public int[] ConnectedLineStyle { get; set; }this[int]
Section titled “this[int]”Gets or sets the tab item at the specified index.
public TabItem this[int index] { get; set; }Methods
Section titled “Methods”AddTab(TabItem)
Section titled “AddTab(TabItem)”Adds a tab to the control.
public void AddTab(TabItem tab)Parameters
Section titled “Parameters”tab TabItem
TabItem with header and associated console for tab content
AddTab(string, Panel)
Section titled “AddTab(string, Panel)”Creates and adds a tab to the control.
public TabItem AddTab(string header, Panel content)Parameters
Section titled “Parameters”header string
The header of the new tab.
content Panel
Associated content for the new tab.
Returns
Section titled “Returns”TabItem
The new tab item.
RemoveTab(TabItem)
Section titled “RemoveTab(TabItem)”Removes a tab from the control.
public void RemoveTab(TabItem tab)Parameters
Section titled “Parameters”tab TabItem
TabItem that should be removed
RemoveTab(int)
Section titled “RemoveTab(int)”Removes a tab by index.
public void RemoveTab(int index)Parameters
Section titled “Parameters”index int
The index of the tab to remove.
SetActiveTab(int)
Section titled “SetActiveTab(int)”Sets the tab specified by the index as active.
public void SetActiveTab(int index)Parameters
Section titled “Parameters”index int
Index of the tab.
OnActiveTabItem(int, int)
Section titled “OnActiveTabItem(int, int)”Raises the ActiveTabItemChanged event.
protected void OnActiveTabItem(int previousActiveIndex, int activeIndex)Parameters
Section titled “Parameters”previousActiveIndex int
The tab index of the previous item.
activeIndex int
The index of the active tab.
GetTabIndex(TabItem)
Section titled “GetTabIndex(TabItem)”Gets the index of a tab
public int GetTabIndex(TabItem tab)Parameters
Section titled “Parameters”tab TabItem
Tab you need the index of
Returns
Section titled “Returns”int
0 based index of the tab
ContainsTab(TabItem)
Section titled “ContainsTab(TabItem)”Determines whether a tab is contained in this control.
public bool ContainsTab(TabItem tab)Parameters
Section titled “Parameters”tab TabItem
The tab to check.
Returns
Section titled “Returns”bool
Returns true when the tab is in the control; otherwise, false.
SelectNextTab()
Section titled “SelectNextTab()”Sets the next tab as active. Stops at the last tab.
public bool SelectNextTab()Returns
Section titled “Returns”bool
Returns true when the active tab changes; otherwise, false.
SelectPreviousTab()
Section titled “SelectPreviousTab()”Sets the previous tab as active. Stops at the first tab.
public bool SelectPreviousTab()Returns
Section titled “Returns”bool
Returns true when the active tab changes; otherwise, false.
OnLeftMouseClicked(ControlMouseState)
Section titled “OnLeftMouseClicked(ControlMouseState)”Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The current mouse data
OnMouseIn(ControlMouseState)
Section titled “OnMouseIn(ControlMouseState)”Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.
protected override void OnMouseIn(ControlBase.ControlMouseState state)Parameters
Section titled “Parameters”state ControlBase.ControlMouseState
The current mouse data
OnResized()
Section titled “OnResized()”Resizes the tab item.
protected override void OnResized()ThemeDetermineContentRegion()
Section titled “ThemeDetermineContentRegion()”Sets the ContentRegion rectangle to how much space the tab control should give to tab item content.
protected void ThemeDetermineContentRegion()UpdateAndRedraw(TimeSpan)
Section titled “UpdateAndRedraw(TimeSpan)”Updates each control hosted by this control.
public override void UpdateAndRedraw(TimeSpan time)Parameters
Section titled “Parameters”time TimeSpan
The game frame time delta.
Events
Section titled “Events”ActiveTabItemChanged
Section titled “ActiveTabItemChanged”Raised when the active tab changes.
public event EventHandler<ValueChangedEventArgs<TabItem?>>? ActiveTabItemChanged