Wednesday, 7 March 2012

Building a Listview Control

A Listview uses an imagelist to create groups and assign numbers to them as per list criterias. Columnheaders are created and listitems and list subitems are added to them.
ListView1.Icons = ImageList1
ListView1.SmallIcons = ImageList2
ListView1.ColumnHeaderIcons = ImageList3
Dim clmx As ColumnHeader
Set clmx = ListView1.ColumnHeaders.Add(, , " EL Magazine Member Groups", , , 1)
Set clmx = ListView1.ColumnHeaders.Add(, , "Free", , , 2)
Set clmx = ListView1.ColumnHeaders.Add(, , "Subscription", , , 3)
Dim itmx1 As ListItem
Dim itmx2 As ListItem
Dim itmx3 As ListItem
Set itmx1 = ListView1.ListItems.Add(, "NR", "North", 1, 1)
itmx1.Selected = False
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "14", 0
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "25", 0
Set itmx2 = ListView1.ListItems.Add(, , "East", 1, 1)
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "04", 0
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "28", 0
Set itmx3 = ListView1.ListItems.Add(, , "West", 1, 1)
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "12", 0
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , "15", 0
     
ListView1.View = lvwReport
End Sub

No comments:

Post a Comment