Results 1 to 3 of 3

Thread: MultiColumn ListBoxes

  1. #1

    Thread Starter
    Lively Member iataman's Avatar
    Join Date
    Jun 2000
    Location
    Turkey
    Posts
    71

    Question

    Hi.

    I've problems about using listboxes. I dont know how to use multicolumn listboxes, how to add items etc.

    In VB for Applications I was using :

    List1.Additem ""
    List1.list(1,0) ="Column1"
    List2.list(1,1) ="Column1"

    but it does not work in VB6.

    Thanks in Advance.


  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655

    Thumbs up

    Try using a listview control instead:

    Code:
    Private Sub Form_Load()
    Dim objItem As ListItem
    'set it so you can see the columns
    ListView1.View = lvwReport
    'create headers
    ListView1.ColumnHeaders.Add , , "Product"
    ListView1.ColumnHeaders.Add , , "Price"
    
    'set first column data
    Set objItem = ListView1.ListItems.Add(, "Phone", "Telephone")
        'set second column data
        objItem.SubItems(1) = "$50.00"
    Set objItem = ListView1.ListItems.Add(, "Car", "Car")
        objItem.SubItems(1) = "$58,500.00"
    Set objItem = ListView1.ListItems.Add(, "book", "Tale of Two Cities")
        objItem.SubItems(1) = "$15.00"
    End Sub
    Let me know if you need any further clarification.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ...or..

    'you could use tabs to give the illusion of columns
    'set tab stops in a listbox
    'appears as columns
    '
    Option Explicit
    '
    Public Declare Function SendMessageArray Lib _
    "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long

    Public Const LB_SETTABSTOPS = &H192

    '<<<<< code for form >>>>>
    '
    Private Sub Command1_Click()

    List1.AddItem "Nothing More"
    List1.AddItem "Nothing Less"
    List1.AddItem "Just A Sample"

    Dim r As Long

    'set up the tabstops in the listboxes
    ReDim TabStop(1 To 3) As Long

    'assign values to the tabs for the second third and fourth
    'column (the first is flush against the listbox edge ie...0)
    TabStop(1) = 80
    TabStop(2) = 160
    TabStop(3) = 240

    'set the tabs
    r = SendMessageArray(List1.hwnd, LB_SETTABSTOPS, 3, TabStop(1))
    List1.Refresh
    List1.AddItem "...A lesson" & vbTab & "in creating" & vbTab & "columns" & vbTab & "in a listbox!"


    End Sub

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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