Hello all,
I have a form of 4 tabcontrol, I want to put the next button on each tab so that when the user press it, it goes to the next tab.
How will i do that.
Please, help me out.

Use tab control's SelectedIndex property to change tab page. Here's a simple sample snippet

Public Class Form2

  Private m_CurrentIndex As Integer

  Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    '
    m_CurrentIndex = 0 ' Start with first tab

  End Sub

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    '
    ' Increase index
    m_CurrentIndex += 1
    ' Check that index is in the bounds
    If m_CurrentIndex >= 0 AndAlso m_CurrentIndex < TabControl1.TabCount Then
      ' Show next tab page
      TabControl1.SelectedIndex = m_CurrentIndex
    End If

  End Sub

End Class

To test it, drop a tab control on a form and put a button control in the first tab page. Notice that you may have to change control names in the code above.

HTH

private void btnNext_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = tabControl1.TabIndex + 1;
            
        }

Edited 7 Years Ago by __avd: Use [code] tags to wrap code.

int currenttab = 0;
        private void Next_Click(object sender, EventArgs e)
        {
                currenttab = tabControl1.SelectedIndex;
                currenttab = currenttab + 1;
            if (currenttab < tabControl1.TabCount)
            {
                tabControl1.SelectedIndex = currenttab;
                
            }
            
        }
private void Back_Click(object sender, EventArgs e)
        {
             currenttab = tabControl1.SelectedIndex;
             currenttab = currenttab - 1;
            if (currenttab >-1 )
            {
                tabControl1.SelectedIndex = currenttab;
                
            }
            
        }

Edited 7 Years Ago by __avd: Use [code] tags to wrap code.

This article has been dead for over six months. Start a new discussion instead.