Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding controls to a tab control at runtime.

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello,

VS 2005

This works but i am wondering is there a better way to do this. I will be having combo boxes, text boxes, buttons and list boxes and labels.

The layout of each tab will be the same. As the user click add task it will add a new tab the controls will be added and some controls will be bounded by tables in a database.

The user will then add some data into some of the text boxes and click save. The contents will be saved to the database.

My code is below and this is just a start. If anyone know of a better more efficient then I will be happy to learn from them.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.TabControl1.TabPages.Add("Index1", "Task 123")
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim cboClients As New ComboBox
        cboClients.Top = 30
        cboClients.Left = 30
        AddHandler cboClients.SelectionChangeCommitted, AddressOf ComboBox_selectionChangeCommitted

        cboClients.Parent = Me.TabControl1.TabPages(1) 'Add the combo box the specified tab
    End Sub

    Private Sub ComboBox_selectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Fill the combo box
    End Sub

Many thanks in advance,

Steve
 
Hello

Thanks for the tip.

Is it possible to have some code that will get me started on what you suggested. I am interested to learn a bit more about this.

Many thanks,

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top