Activate tabpage of TabControl

2019-01-17 13:59发布

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?

5条回答
放荡不羁爱自由
2楼-- · 2019-01-17 14:12

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

     mytabControl.SelectedIndex = 1
查看更多
▲ chillily
3楼-- · 2019-01-17 14:15
tabControl1.SelectedTab = MyTab;
查看更多
来,给爷笑一个
4楼-- · 2019-01-17 14:23

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
查看更多
成全新的幸福
5楼-- · 2019-01-17 14:31

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);
查看更多
霸刀☆藐视天下
6楼-- · 2019-01-17 14:31

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.

查看更多
登录 后发表回答