24

How do I change the tabpage being displayed in my tabcontrol programmatically?

Goober
  • 13,146
  • 50
  • 126
  • 195

2 Answers2

45

Either by tabControl1.SelectedIndex which is an integer or if you have a reference to a particular tab, tabControl1.SelectedTab.

If you wanted the first one selected:

tabControl1.SelectedIndex = 0;
Joshua Belden
  • 10,273
  • 8
  • 40
  • 56
10

Other alternatives to the accepted answer:

tabControl1.SelectedTab = MyTabPage;

or tabControl1.SelectTab("NameOfTabToActivate");

or tabControl1.SelectTab(IndexOfTab);

or tabControl1.SelectTab(TabObject);

(I stole this answer from this post: Activate tabpage of TabControl)

Community
  • 1
  • 1
amalgamate
  • 2,200
  • 5
  • 22
  • 44