This example adds three ListImage objects to a ListImages collection and uses them in a ListView control. The code refers to the ListImage objects using both their Key and Item properties. To try the example, place ImageList and ListView controls on a form and paste the code into the form's Declarations section. Run the example.
Private Sub Form_Load()
Dim imgX As ListImage
' Add images to ListImages collection.
Set imgX = ImageList1. _
ListImages.Add(,"rocket",LoadPicture("icons\industry\rocket.ico"))
Set imgX = ImageList1. _
ListImages.Add(,"jet",LoadPicture("icons\industry\plane.ico"))
Set imgX = ImageList1. _
ListImages.Add(,"car",LoadPicture("icons\industry\cars.ico"))
ListView1.Icons = ImageList1 ' Set Icons property.
' Add Item objects to the ListView control.
Dim itmX as ListItem
Set itmX = ListView1.ListItems.Add()
' Reference by index.
itmX.Icon = 1
itmX.Text = "Rocket" ' Set Text string.
Set itmX = ListView1.ListItems.Add()
' Reference by key ("jet").
itmX.Icon = "jet"
itmX.Text = "Jet" ' Set Text string.
Set itmX = ListView1.ListItems.Add()
itmX.Icon = "car"
itmX.Text = "Car" ' Set Text string.
End Sub