Change tab of the TabControl

2

I'm creating a WindowsForm form and I'm using a TabControl and would like to create an event that would change the tab being displayed.

I was able to change the content displayed with this.tabForm.TabPages["nomeTab"].Show(); or tabPage1.Show(); , both options worked, but only the content being displayed is changed, the selected tab remains the same.

How do I solve this problem?

    
asked by anonymous 17.11.2018 / 18:26

2 answers

1

There are several ways to change the selected tab / tab in a TabControl .

SelectedIndex

tabControl.SelectedIndex = 1;

SelectedTab

// aqui a atribuição é feita pelo objeto do separador/tabulador
tabControl.SelectedTab = tabPage;

SelectTab()

// aqui é evocado um método para selecionar o separador/tabulador
// tem 3 overloads: 
//      index (int)           = por índice
tabControl.SelectTab(0);
//      tabPageName (string)  = por nome
tabControl.SelectTab("tabPage");
//      tabPage (TabPage)     = por objeto
tabControl.SelectTab(tabPage);
    
19.11.2018 / 15:00
1

I was able to change using the selectedindex of tabcontrol, eg: tabControl.SelectedIndex = 1;

    
19.11.2018 / 00:50