C# – How to programmatically select a tab on a .NET CF TabControl

.netc++compact-frameworktabcontrol

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?

Best Solution

TabControl.SelectedIndex