[c#] Activate tabpage of TabControl

I am using TabControl in #.NET application. By default first tab page of TabControl is showing in form loading. I want to activate/show other tab pages in form loading. Programmatically, how can I show other tab page?

This question is related to c# winforms tabcontrol tabpage

The answer is


There are two properties in a TabControl control that manages which tab page is selected.

SelectedIndex which offer the possibility to select it by index (an integer starting from 0 to the number of tabs you have minus one).

SelectedTab which offer the possibility to selected the tab object itself to select.

Setting either of these property will change the currently displayed tab.

Alternatively you can also use the Select method. It comes in three flavour, one where you pass the index of the tab, another the TabPage object itself and the last one a string representing the tab's name.


Use SelectTab like this:

TabPage t = tabControl1.TabPages[2];
tabControl1.SelectTab(t); //go to tab

Use SelectedTab like this:

TabPage t = tabControl1.TabPages[2];
tabControl1.SelectedTab = t; //go to tab

You can use the method SelectTab.

There are 3 versions:

public void SelectTab(int index);
public void SelectTab(string tabPageName);
public void SelectTab(TabPage tabPage);

For Windows Smart device (compact frame work ) (MC75-Motorola devices)

     mytabControl.SelectedIndex = 1

Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to winforms

How to set combobox default value? Get the cell value of a GridView row Getting the first and last day of a month, using a given DateTime object Check if a record exists in the database Delete a row in DataGridView Control in VB.NET How to make picturebox transparent? Set default format of datetimepicker as dd-MM-yyyy Changing datagridview cell color based on condition C# Inserting Data from a form into an access Database How to use ConfigurationManager

Examples related to tabcontrol

Check if a specific tab page is selected (active) Activate tabpage of TabControl Hiding and Showing TabPages in tabControl WPF TabItem Header Styling Is there Selected Tab Changed Event in the standard WPF Tab Control How to hide TabPage from TabControl How can I disable a tab inside a TabControl?

Examples related to tabpage

Can't Load URL: The domain of this URL isn't included in the app's domains Check if a specific tab page is selected (active) Activate tabpage of TabControl Hiding and Showing TabPages in tabControl How to hide TabPage from TabControl