views:

1236

answers:

2

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?

+2  A: 

TabControl.SelectedIndex

Cheeso
Don't know how I missed that. Thanks.
raven
A: 

WPF code, try this:

if (tabControl1.SelectedValue == tabPage1)
    tabControl1.SelectedValue = tabPage2;
else
    tabControl1.SelectedValue = tabPage1;
Mark Kadlec
WPF and the Compact framework don't mix, don't they...? (Or did I miss something?)
peSHIr
Plus, this is exactly what the question says does not work: a working alternative was called for.
peSHIr
Sorry, I did miss the Compact statement but I believe SelectedValue will work in the compact framework, it is missing SelectedTab.
Mark Kadlec