Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Gillingham, Kent, England
    Thanked 0 Times in 0 Posts

    Populating Tabs (VB6)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    The basic question is: I need a tab control that I can dynamically add tabs to and each tab could either hold a grid control or a picturebox containing what would usually go straight on a form. Does anyone have any suggestions on the best way to go about this?

    I currently have a form (not MDI) with a tab control on it. I'm using Xceeds smartUI component ( which uses pictureboxes to populate its tabs, but the component isn't the issue, so that doesn't matter so much.

    If I continue with the SmartUI control ill need to populate everything in picture boxes and build everything on the form with the tab control (although I am waiting for a response from Xceed regarding passing pictureboxes from other forms to it):

    For the grids i'd like to programatically create a picturebox, then create a grid inside the picture box, however the grid may need to be array so I can identify the events easily. I managed to create a picturebox on the form, but I don't know how to find a controls ProgID which I think I need to be able to add the grid.

    For the pre-designed tabs, I was hoping to create the tab in a picturebox on a form at design time, then at runtime, create a variable from the picturebox and create a new instance of it on the form with the tab. I have seen something along these lines before but it was a while ago and all I can remember is that it used the hWnd variable, after trying this I just got a read only error.

    If anyone can help, give pointers, suggest websites or anything with any of this or suggest a better method of doing it then it would be much appreciated as I am more than a bit stuck. The words "too much at once" have come to mind!

  2. #2
    2 Star Lounger
    Join Date
    Jun 2002
    Thanked 0 Times in 0 Posts

    Re: Populating Tabs (VB6)

    Not sure if this will help but...

    I think you can find a way to dynamically add tabs to a tab control in the Access 97 Developer's Handbook, by Litwin, Getz, and Gilbert (Sybex) Copyright 1997. Their code may give you a start.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Gillingham, Kent, England
    Thanked 0 Times in 0 Posts

    Re: Populating Tabs (VB6)

    Thanks accdb but I was more trying to work out how to populate the tabs, opposed to actually adding them.
    I have just managed to work it out. The function is as follows:

    Public Function TabAdd(STab As Object, SContainer As Object, TKey As String, TCaption As String, TabFrame As Object, FrmObject As Object) As String
    On Error GoTo err:
    Dim FIndex As Integer
    'Add the tab (Using xceeds SmartUI tab control)
    STab.SmartItems.Add , TKey, TCaption, TabFlat, TKey
    'Add the corresponding container
    SContainer.SmartItems.Add , TKey, , MiscObject
    'Determine the new frames index
    For Each Item In TabFrame
    FIndex = Item.Index + 1
    Next Item
    'Load the frame
    Load TabFrame(FIndex)
    'Set the frames default properties
    With TabFrame(FIndex)
    .Visible = True
    .Left = 0
    .Top = 0
    .Height = 3000
    .Width = 3000
    .BackColor = &HFFFFFF
    End With
    SetParent FrmObject.hWnd, TabFrame(FIndex).hWnd
    SContainer(TKey).Value = "TabFrame(" & FIndex & ")"
    TabAdd = "success"
    Exit Function
    TabAdd = err.Number & ": " & err.Description
    End Function

    I can either pass an object or control directly from a form, or create an object dynamically and pass it to frmobject and whatever is in it appears on a new tab.

    A general BIG thank you for various bits of info I got from various replies and other posts on Woody's and a couple of other places, mainly regarding:
    Creating a new instance of a form as a variable
    Assinging a controls parent
    Creating object arrays dynamically

    Thanks again everyone.

Posting Permissions

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