TabControl Class

The TabControl class is used to add tabs to a form. Tabs provide a way to save space and avoid a cluttered and confusing UI when many controls are needed in a form. To use a tab control in a form, first create an object of type TabControl and add it to the form. Objects of type TabPage can then be created, populated with other controls such as buttons and checkboxes, and added to the tab control. The currently selected tab is identified by the tab control’s SelectedIndex property.

var: TabControl allTabs(null), TabPage myTab1(null); // declare a TabControl and TabPage

{declare other form controls}

 

myTab1 = TabPage.Create("FirstTab",400,300); // create a tab page with a button and label

myTab1.AddControl(aButton);

myTab1.AddControl(aLabel);

 

allTabs = TabControl.Create(); // create a tab control and add a tab page

allTabs.AddControl(myTab1);

 

{create other form controls and add them all to a form}

For more information, see Using Form Classes.

Namespace: elsystem.windows.forms

Properties

   Additional properties, methods, and events are described in the classes listed under Inheritance Hierarchy (see below).

  Name Type Description
Public property Multiline bool Gets or sets a value that determines whether more than one line of tabs can be displayed. Set to true to allow more than one line of tabs. Set to false to not allow more than one line of tabs.
Public property SelectedIndex int Gets the zero-based index of the currently selected tab.
Public property SelectedTab object Gets or sets the selected TabPage.
Public property TabCount int Gets the number of tabs.
Public property TabPages object Gets a TabPageCollection that contains the TabControl's TabPages.
Methods
  Name Description
Public property Create() Initializes a new instance of a TabControl.  
Public property SelectTab(Index) Makes the tab with the specified index number the current tab.  
Public property SelectTab(TabPage) Makes the specified TabPage the current tab.  
Public property SelectTab(PageName) Makes the tab with the specified name the current tab.  
Events
  Name Description
Public event Deselected

Occurs when a tab is selected. See TabControlEventArgs for the properties returned by the handler's args parameter.

Public event Selected

Occurs when a tab is selected. See TabControlEventArgs for the properties returned by the handler's args parameter.