Click here to Skip to main content
15,892,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i need to control 3 tab pages in separate 3 buttons.this code doesn't give any errors but not working as expected.tabpages are not appearing when the given buttons are clicked.
please help me!

private void button1_Click(object sender, EventArgs e)
{
    tabPage1.Show();
}
private void button2_Click(object sender, EventArgs e)
{
    tabPage2.Show();
}
private void button3_Click(object sender, EventArgs e)
{
    tabPage3.Show();
}
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jul-11 13:14pm    
There is more than on TabControl class. Which one? Tag it: WPF, Forms, what?
--SA

1 solution

You need to set the selected tab like so

C#
private void button1_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage1;
}

private void button2_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage2;
}
      
private void button3_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage3;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900