Change tab of Tabcontrol

Asked

Viewed 311 times

2

I am creating a Windowsform template and I am using a Tabcontrol and would like to create an event that changes the tab that is being displayed.

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

How do I solve this problem?

  • 1

    I usually change the tabcontrol selectedindex, e.g.: tabControl.Selectedindex = 1;

  • I did it that way and it worked. Thank you Lucas.

  • Good evening, Vinicius, answer your question and mark it as right to organize the community

2 answers

1


There are several ways to change the selected tab/tab in one 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);

1

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.