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.

Recommended Answers

All 3 Replies

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;
            
        }
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;
                
            }
            
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.