Results 1 to 7 of 7

Thread: MultiColumn ListBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Buenos Aires, Argentina
    Posts
    64

    Angry

    Hi.

    How can i use a multicolumn listbox and then add columns items with the AddItem method of ListBox Control?

    Thanks in advance.

    PD. The ListBox style is CheckBox
    Juan
    Argentina
    VB6 Ent.
    [email protected]

  2. #2
    Guest
    I'm somewhat confused. If all you want to do is add items, use the following:
    Code:
    List1.AddItem "MyItem"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Buenos Aires, Argentina
    Posts
    64
    Yes.Megatron

    I want to add items to a listbox but it must be a multicolumn one and i want to add items in each column.

    thanks.
    Juan
    Argentina
    VB6 Ent.
    [email protected]

  4. #4
    Junior Member
    Join Date
    Aug 2000
    Location
    Manila, Philippines
    Posts
    16

    Smile Multicolumn List Box

    Hi. I don't think the list boxes that come with VB support multicolumns. You should try 3rd party list boxes like APEX True DBList and Sheridan DataWidgets.

  5. #5
    Junior Member
    Join Date
    Aug 2000
    Location
    Manila, Philippines
    Posts
    16
    I just read a suggestion in another forum. Add Microsoft Forms 2.0 Object Library to your components. The combo box and list box included supports multiple columns. I think these are the standard controls of Visual FoxPro.

  6. #6
    Guest
    the ListBox control Can support multicolumns, but the columns are like this

    Code:
    |====================|
    |= 1  4  7  10  13  =|
    |= 2  5  8  11  14  =|
    |= 3  6  9  12  15  =|
    |====================|
    I assume you want it like this


    Code:
      C1   C2  C3 C4  C5
    |=====================|
    |=C1-1=C2-1=C3-1=4-10=|
    |=C1-2=C2-2=C3-2=4-11=|
    |=C1-3=C2-3=C3-3=4-12=|
    |=====================|
    am I right?

    For that you must use a ListView Control with the View property set to Report, then under the Custom Property, add the Column Headers and add the caption, etc.

    The ListView Control is in Microsoft Windows Common Controls 6.0.

    Dennis

    [Edited by denniswrenn on 08-25-2000 at 01:58 AM]

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You can set tabstops in a listbox and then add tab separated items to the listbox.
    Here's an example that uses 5 columns (i.e 4 tabs):
    Code:
    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 As Long = &H192
    
    Private Sub Form_Load()
        ReDim TabArray(0 to 3) As Long
    
        TabArray(0) = 49
        TabArray(1) = 100
        TabArray(2) = 151
        TabArray(3) = 202
        'Clear any existing tabs 
        'and set the list tabstops
        SendMessage List1.hwnd, LB_SETTABSTOPS, 0&, ByVal 0&
        SendMessage List1.hwnd, LB_SETTABSTOPS, 4&, TabArray(0)
        List1.Refresh
        List1.AddItem "Col1" & vbTab & "Col2" & vbTab _
         & "Col3" & vbTab & "Col4" & vbTab & "Col5"
    End Sub
    I used the CCRP's CoolTabs Visual Tabstop designer to generate this code. You can download it at http://www.mvps.org/ccrp (click on the "cooltools" link).

    Good luck!

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