Results 1 to 2 of 2

Thread: Listview Control

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    15
    I have a listview control on my form with the report style.
    I am running a piece of code which populates this list with about 20 items, but each item contains two bits of data.

    Is it possible to put the first piece of data in the first column and the second in the second. and do the same for every item all the way down the list?

    e.g

    Header1 Header2
    Item1Data1 Item1Data2
    Item2Data1 Item2Data2 and so on.......
    If practice makes perfect...

    and nobody's perfect...

    why the hell practice?

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Sure, just create 2 columns and use the SubItems Object of the added Item to set the 2nd column, i.e.
    Code:
    Private Sub Form_Load()
        Dim lIndex As Long
        Dim oNewItem As ListItem
        
        With ListView1
            .View = lvwReport
            .ColumnHeaders.Add , , "Header1"
            .ColumnHeaders.Add , , "Header2"
            For lIndex = 1 To 20
                Set oNewItem = .ListItems.Add(, , "Item " & lIndex)
                oNewItem.SubItems(1) = "Data " & lIndex
            Next
        End With
    End Sub

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