Results 1 to 3 of 3

Thread: Listbox colums

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    How do I put seperate data from a 2D array into different colums on a listbox?

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi Steve,
    Give this a try:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    'set the listview to report mode
    ListView1.View = lvwReport
    'just a test 2-dimensional array
    Dim TempArray(2, 2) As String
    TempArray(1, 1) = "TestData11"
    TempArray(1, 2) = "TestData12"
    TempArray(2, 1) = "TestData21"
    TempArray(2, 2) = "TestData22"
    
    'add the two column headers
    ListView1.ColumnHeaders.Add , , "Data1"
    ListView1.ColumnHeaders.Add , , "Data2"
    
    'loop variable
    Dim i As Integer
    'listitem object
    Dim LVItem As ListItem
    
    For i = 1 To 2
        'Add the first part of the array
        Set LVItem = ListView1.ListItems.Add(, , TempArray(i, 1))
        'Add the second part as a subitem
        LVItem.SubItems(1) = TempArray(i, 2)
    Next i
    End Sub
    Just create a standard exe with a listview on it.

    You can change the code to fit your own needs.

    Hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Thumbs up

    That was even better than what I was looking for! Thanks!

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