How do I change the tabpage being displayed in my tabcontrol programmatically?
Asked
Active
Viewed 5.8k times
2 Answers
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
-
1The simplest thing to do, yet I always have to look it up...my memory cells must be fading... – IAbstract Feb 23 '11 at 19:54
-
big tnx! I was since always do it in bad way! Tnx for this solution :) – netmajor Mar 26 '11 at 18:14
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