Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAdd new tabs and controls to a TabStrip
DescriptionThis example shows how to add new tabs and controls to a TabStrip control in Visual Basic 6. It uses the TabStrip's Tabs.Add method to make a new tab. It then uses Load to make a Frame control and the controls it should hold.
KeywordsControls.Add, new control, new tab, TabStrip
CategoriesControls, Tips and Tricks
 
This example uses the TabStrip control's Tabs.Add method to make a new tab. It uses Load to make a new Frame control to hold the controls for the tab and positions it over the TabStrip.

Next the program uses Load to make the controls that should sit inside the new tab and sets their Container properties to the new Frame.

 
' Create a new address tab.
Private Sub cmdAddTab_Click()
Dim frame_index As Integer
Dim cbo_item As Integer

    ' Create the new tab.
    tabSections.Tabs.Add , , "Address " & _
        Format$(tabSections.Tabs.Count + 1)

    ' Create the new frame.
    frame_index = tabSections.Tabs.Count - 1
    Load fraTab(frame_index)
    ' Make the new frame set on top of the TabStrip.
    fraTab(frame_index).ZOrder
    ' Position the frame over the TabStrip.
    PositionFrame fraTab(frame_index)

    ' Make the new fields for the frame.
    Load lblName(frame_index)
    With lblName(frame_index)
        Set .Container = fraTab(frame_index)
        .Move lblName(0).Left, lblName(0).Top
        .Visible = True
    End With

    Load lblAddress(frame_index)
    With lblAddress(frame_index)
        Set .Container = fraTab(frame_index)
        .Move lblAddress(0).Left, lblAddress(0).Top
        .Visible = True
    End With

    Load lblCity(frame_index)
    With lblCity(frame_index)
        Set .Container = fraTab(frame_index)
        .Move lblCity(0).Left, lblCity(0).Top
        .Visible = True
    End With

    Load lblState(frame_index)
    With lblState(frame_index)
        Set .Container = fraTab(frame_index)
        .Move lblState(0).Left, lblState(0).Top
        .Visible = True
    End With

    Load lblZip(frame_index)
    With lblZip(frame_index)
        Set .Container = fraTab(frame_index)
        .Move lblZip(0).Left, lblZip(0).Top
        .Visible = True
    End With

    Load txtName(frame_index)
    With txtName(frame_index)
        Set .Container = fraTab(frame_index)
        .Move txtName(0).Left, txtName(0).Top
        .Visible = True
    End With

    Load txtAddress(frame_index)
    With txtAddress(frame_index)
        Set .Container = fraTab(frame_index)
        .Move txtAddress(0).Left, txtAddress(0).Top
        .Visible = True
    End With

    Load txtCity(frame_index)
    With txtCity(frame_index)
        Set .Container = fraTab(frame_index)
        .Move txtCity(0).Left, txtCity(0).Top
        .Visible = True
    End With

    Load cboState(frame_index)
    With cboState(frame_index)
        Set .Container = fraTab(frame_index)
        .Move cboState(0).Left, cboState(0).Top
        For cbo_item = 0 To cboState(0).ListCount - 1
            .AddItem cboState(0).List(cbo_item)
        Next cbo_item
        .Visible = True
    End With

    Load txtZip(frame_index)
    With txtZip(frame_index)
        Set .Container = fraTab(frame_index)
        .Move txtZip(0).Left, txtZip(0).Top
        .Visible = True
    End With
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated