How do I programatically select a Tab Page?
-
I have 6 tabs on my windows forms. I want it to change tabs with I click the next button can you any help.
Shelby Learning the Code!
Call
SelectedTab
and select the tab you want.Deja View - the feeling that you've seen this post before.
-
Call
SelectedTab
and select the tab you want.Deja View - the feeling that you've seen this post before.
private void Navigate() { //this.tabControl1.SelectedTab = this.tabPage1; //this.tabControl1.SelectedTab = this.tabPage2; //this.tabControl1.SelectedTab = this.tabPage3; //this.tabControl1.SelectedTab = this.tabPage4; //this.tabControl1.SelectedTab = this.tabPage5; } This is what I have. I need with I click the Next button it on to tab 2 if I press again tab 3 and so on. I click the previous button it goes backward.
Shelby Learning the Code!
-
private void Navigate() { //this.tabControl1.SelectedTab = this.tabPage1; //this.tabControl1.SelectedTab = this.tabPage2; //this.tabControl1.SelectedTab = this.tabPage3; //this.tabControl1.SelectedTab = this.tabPage4; //this.tabControl1.SelectedTab = this.tabPage5; } This is what I have. I need with I click the Next button it on to tab 2 if I press again tab 3 and so on. I click the previous button it goes backward.
Shelby Learning the Code!
So keep track of which tab you're on and use that as the basis for navigation.
Deja View - the feeling that you've seen this post before.
-
So keep track of which tab you're on and use that as the basis for navigation.
Deja View - the feeling that you've seen this post before.
-
Name 2 buttons "btnPrev" and "btnNext". Name a tab control "tabControl1". Create "Click" event handlers for the two buttons and put the code in them like this:
private void btnPrev_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex > 0)
tabControl1.SelectedIndex--;
}private void btnNext_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex < (tabControl1.TabCount - 1))
tabControl1.SelectedIndex++;
}