Results 1 to 4 of 4

Thread: Creating and using tabcontrols at runtime

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    6

    Creating and using tabcontrols at runtime

    Hi Guys,
    This is the first time I have wanted to use tabstrips and have a couple of questions .
    I can build the tabstrip fine and name it - that part is from what I can see the easy bit.
    What I want to do is select a tab then create a listbox on that tab, and then pupulate the list box with data.
    For this test I am using the event viewer.

    The system loades the logs into memory, and then creates however many system logs there are ie application, system security etc etc.

    But how the hell do I select one of these tabs then draw a listbox and then address the list box - Ideally the list boxes etc will be created at the time of the tab ?

    Here is my code for this (By the way its VB 2010)
    Code:
            Dim log As EventLog
            Dim lstname As String
    
            'Gets logs on the local machine
            remoteEventLogs = EventLog.GetEventLogs(System.Environment.MachineName)
    
            'Create the Tab's
            For Each log In remoteEventLogs
    
                TabControl1.Controls.Add(New TabPage(log.Log))
                Dim tp As New TabPage
                tp.Text = log.Log
                Me.TabControl1.TabPages.Add(tp)
                Me.TabControl1.SelectedTab = tp
    
            Next log
    
            'now select a tab and create a list box ??
            Me.TabControl1.SelectTab(1) ' Selected tab 1 just as its the first
            ' Create an instance of the ListBox.
            Dim listBox1 As New ListBox()
            ' Set the size and location of the ListBox.
            listBox1.Size = New System.Drawing.Size(1055, 537)
            listBox1.Location = New System.Drawing.Point(106, 7)
            ' Add the ListBox to the form.
            selectedtab.Controls.Add(listBox1)
    Thanks for your help in advance

    Jez
    Last edited by VBnewbie1001; Jan 23rd, 2011 at 11:01 AM. Reason: forgot to add version of VB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width