tabcontrol Navigation

Rhayezelle

Member
Joined
Aug 14, 2010
Messages
24
Location
Philippines
Programming Experience
Beginner
please help.. I'm still a newbie in vb.net..

here's my code

'------ go to next tabpage ----------'

cmdnext_click
tabcontrolPI.selectab(+1)

'---- it went wrong here-------------'
cmdprevious_click
tabcontrolPI.selectab(-1)


can you please teach me the right code for this?? that when i had clicked the previous button it would go to the previous tabpage.... :(
 
SelectedIndex is probably easiest to work with, adding/subtracting 1 to current, but check with lower bounds (0) and upper bounds (TabCount-1) first.

next
VB.NET:
If Me.TabControl1.SelectedIndex < (Me.TabControl1.TabCount - 1) Then
    Me.TabControl1.SelectedIndex += 1
End If
previous
VB.NET:
If Me.TabControl1.SelectedIndex > 0 Then
    Me.TabControl1.SelectedIndex -= 1
End If
You can also use this check to enable/disable the appropriate button to only allow the user to click it if the action is actually available.
 
Back
Top