-
I just discovered the ListView control and want to know how to add items to it.. I don't have access to my MSDN cd right now so I can't lookup the help..
My idea is to populate the listview from data in an Access table via ADO.. I don't need help on accessing the database, just help on populating the listview with an ADO recordset..
Any examples or help would be appreciated..
Dan
-
<?>
'just change the items form the rnd to rs!fields
Code:
Dim l As Long
Dim dblRnd As Double
Dim dteRnd As Date
With ListView1
' Add three columns to the list - one for each data type.
' Note that the data type is set in the column header's
' tag in each case
'
.ColumnHeaders.Add(, , "String").Tag = "STRING"
.ColumnHeaders.Add(, , "Number").Tag = "NUMBER"
.ColumnHeaders.Add(, , "Date").Tag = "DATE"
'
' Set the column alignment - has no bearing on the sorts.
'
.ColumnHeaders(1).Alignment = lvwColumnLeft
.ColumnHeaders(2).Alignment = lvwColumnRight
.ColumnHeaders(3).Alignment = lvwColumnCenter
'
' Set BorderStyle property.
ListView1.BorderStyle = ccFixedSingle
'
' Set View property to Report.
ListView1.View = lvwReport
'
' Populate the list with data
With .ListItems
For l = 1 To 100
With .Add(, , "ListItem " & Format(l, "0000"))
dblRnd = (Rnd() * 10000) - 5000
dteRnd = (Rnd() * 1000) + Date
.ListSubItems.Add , , Format(dblRnd, "0.00")
.ListSubItems.Add , , Format(dteRnd, _
"dd/mm/yyyy")
End With
Next l
End With
End With
'