All the images contained in the ImageList control
are stored in the ListImages Collection. Each icon
and bitmap in the collection is a separate ListImage object.
You can refer to each image in the list by its index:
ImageList1.ListImages(1).Picture
or, if a key (for example, "Smiley") were assigned to a particular
ListImage object, you could refer to it by its key value:
ImageList1.ListImages("Smiley").Picture
You can use the ListImages Collection to loop through
all the images in the list. If you wanted to display all the stored images in
a PictureBox, one after another, you could use the
code of Listing 4.1.
LISTING 4.1
LOOPING THROUGH THE
IMAGES IN AN IMAGELIST CONTROL
Dim picImage as ListImage
For Each picImage in ImageListImageList1.ListImages
Picture1.Picture = picImage.Picture
Next
If you knew the image you wanted to move to a PictureBox,
you could just code this:
Picture1.Picture = ImageList1.ListImages(3).Picture
or this:
Picture1.Picture = ImageList1.ListImages("Smiley").Picture
In the first example, the third image in the ImageList
control would be loaded into PictureBox Picture1,
and in the second example, the image whose key is FirstImage
would be loaded.
Related topics on ImageList Control