Goober
Goober

Reputation: 13508

C# TabControl TabPage Change

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

Upvotes: 25

Views: 60956

Answers (2)

amalgamate
amalgamate

Reputation: 2300

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)

Upvotes: 10

Joshua Belden
Joshua Belden

Reputation: 10503

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;

Upvotes: 46

Related Questions