|
|
Title | Use the TabStrip control |
Description | This example shows how to use the TabStrip control in Visual Basic 6. |
Keywords | TabStrip |
Categories | Controls |
|
|
Place containers for each tab on the form. During form load, move them so they are all the same size in the same position, and make them all invisible. When the user clicks on a tab, make the correct container visible.
|
|
' Note that the TabStrip numbers tabs starting
' with 1 not 0.
' The index of the selected frame.
Private SelectedTab As Integer
Private Sub Form_Load()
Dim i As Integer
' Move all the frames to the same position
' and make them all invisible.
For i = 1 To ChoiceFrame.UBound
ChoiceFrame(i).Move _
ChoiceFrame(0).Left, _
ChoiceFrame(0).Top, _
ChoiceFrame(0).Width, _
ChoiceFrame(0).Height
ChoiceFrame(i).Visible = False
Next i
' Select the first tab.
SelectedTab = 1
TabStrip1.SelectedItem = TabStrip1.Tabs(SelectedTab)
ChoiceFrame(SelectedTab - 1).Visible = True
End Sub
Private Sub TabStrip1_Click()
ChoiceFrame(SelectedTab - 1).Visible = False
SelectedTab = TabStrip1.SelectedItem.Index
ChoiceFrame(SelectedTab - 1).Visible = True
End Sub
|
|
This technique is particularly useful in older versions of Visual Basic. In VB6, you can use the Microsoft Tabbed Dialog Control.
|
|
|
|
|
|