WinForms – Change The Active Tab
This question came in last Friday:
I’m trying to code a windows form in vb.net 2005. In my form I have 2 TabControls and a command button. The button is in the first TabControl, so what I want to do, is that when I click the button, in the first TabControl, the second TabControl gets opened.
I’m assuming here that what is really being asked is, “How do I change the active tab in a TabControl from some other event, like a button click in a tab?”
Given a form that looks like this:
Create a Button Click event handler for “Button1″ and set the SelectedIndex property of the TabControl to 1 to activate, “TabPage2″
Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click TabControl1.SelectedIndex = 1 End Sub
If you don’t know the index of the tab you want to activate, you can use the tab object instead:
Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click TabControl1.SelectedTab = TabPage2 End Sub
Other post in winforms
- WinForms - Database Changes not sticking. - April 28th, 2008
- Windows Forms - Passing Parameters at Runtime - March 9th, 2009
- VB.NET Processing Before WinForm Display - August 6th, 2009
- One Form with Multiple Tables - March 24th, 2010
- WinForms - Change The Active Tab - January 15th, 2013
Republished by Blog Post Promoter
Related Post
2 Pingbacks/Trackbacks
- 30 March 2009 at 8:03am
- Dew Drop - March 30, 2009 | Alvin Ashcraft's Morning Dew 31 March 2009 at 8:03am
- Dew Drop - March 31, 2009 | Alvin Ashcraft's Morning Dew
[...] WinForms - Change The Active Tab (Dave M. Bush) ...
[...] WinForms - Change The Active Tab (Dave M. Bush) ...

Pingback: Dew Drop - March 30, 2009 | Alvin Ashcraft's Morning Dew
Pingback: Dew Drop - March 31, 2009 | Alvin Ashcraft's Morning Dew