How do I programmatically select a tab on a .NET CF TabControl?

raven picture raven · May 8, 2009 · Viewed 43.6k times · Source

With the .NET Framework 2.0/3.5 TabControl, I can programmatically select a tab using the SelectedTab property as shown in the code below:

//toggles between tabPage1 and tabPage2
private void button1_Click(object sender, EventArgs e)
{
    if (tabControl1.SelectedTab == tabPage1)
        tabControl1.SelectedTab = tabPage2;
    else
        tabControl1.SelectedTab = tabPage1;
}

The .NET Compact Framework TabControl doesn't have a SelectedTab property like its .NET Framework counterpart. So, how do I select a tab programmatically?

Answer

Cheeso picture Cheeso · May 9, 2009

TabControl.SelectedIndex