Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need multiple columns in ComboBox (VB6)

    I tried this using the following:

    .ComboBox.AddItem Itm.SubItems(1)) & ":" & vbTab & Itm.SubItems(2)

    Though I'm sure ASCII wise it is a tab, but it displays in the ComboBox as one string and represents the vbTab as a box character. It is all run together without actually functioning as a tab.

  2. #17
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need multiple columns in ComboBox (VB6)

    Please accept my sincerest apologies.

    A ListBox control will expand tabs, a ComboBox doesn't appear to do so.

    Regards,

    Kevin Bell

  3. #18
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need multiple columns in ComboBox (VB6)

    You can set the tab stops for a standard VB listbox using the Windows LB_SETTABSTOPS message. For this to work the listbox's Style property must be set to 0 - Standard ( does not work with 1- Checkbox). Simple example: Create new project and add a listbox and command button on form. Add these API declarations to form's code module:

    Private Declare Function SendMessage Lib "User32" _
    Alias "SendMessageA" _
    (ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long

    Private Const LB_SETTABSTOPS = &H192

    Some sample data to populate listbox:

    Private Sub Form_Load()

    List1.AddItem "January Sales" & vbTab & _
    "February Sales" & vbTab & _
    "March Sales"
    List1.AddItem "50" & vbTab & _
    "500" & vbTab & _
    "5000"
    List1.AddItem "10" & vbTab & _
    "100" & vbTab & _
    "1000"

    End Sub

    To set tab stops:

    Private Sub Command1_Click()

    Dim ListBoxTabs(2) As Long
    Dim n As Long

    ListBoxTabs(1) = 75 ' twips
    ListBoxTabs(2) = 150 ' twips

    'Send LB_SETTABSTOPS message to ListBox:
    n = SendMessage(List1.hWnd, LB_SETTABSTOPS, UBound(ListBoxTabs) + 1, ListBoxTabs(1))

    List1.Refresh
    Erase ListBoxTabs

    End Sub

    (See attached example.) Unfortunately for the problem here, there does not appear to be any analagous message that can be used with the VB ComboBox control. But this might be useful when you want to display "columns" in a listbox at specified intervals.

Page 2 of 2 FirstFirst 12

Posting Permissions

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