c# move to next tab in a tab control

16,609

Solution 1

You can simply change the selected index:

tabControl1.SelectedIndex = (tabControl1.SelectedIndex + 1 < tabControl1.TabCount) ?
                             tabControl1.SelectedIndex + 1 : tabControl1.SelectedIndex;

In my example above, the SelectedIndex is increased based on the presently selected index -- if there is an additional tab to change to.

Solution 2

If we're speaking about WinForms TabControl, there is a property SelectedTab

Share:
16,609
Rocshy
Author by

Rocshy

Updated on August 01, 2022

Comments

  • Rocshy
    Rocshy almost 2 years

    I have a TabControl, with 5 TabPages, is there any way I can go through every tab pragmatically? I want to be able to see on what tab the user is, and after he/she clicks a button, the next tab will become available, automatically, so they can write something in that page. Is this possible?

  • serhio
    serhio about 11 years
    this is not the default tab behavior. You should replace the last tabControl1.SelectedIndex by 0...