Say I have a tab control with tabs Tab1 And Tab2. How do I switch the selected tab programmatically, say on button1 click event. Sample code would be appreciated.
Thanks in advance.

Hello jackabascal,

private void button1_Click(object sender, EventArgs e)
        {
            this.tabControl1.SelectedTab = this.tabControl1.TabPages["Tab2"];
        }

Should work
Cheers

The better way to do it is to use the "SelectTab" method

{
   /* Here I declared myTabControl and added three tabs named: "TabOne", "SecondTab", "EndTab"
      I also have an TabPage object bound to "SecondTab" called tabMySecondTab */
   myTabControl.SelectTab(0); // This selects "TabOne" as it is the first in the list
   myTabControl.SelectTab("EndTab"); // This selects the tab "EndTab"
   myTabControl.SelectTab(tabMySecondTab); // This selects the tab "SecondTab"
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.