-
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.......
-
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