ListImages

Description

A ListImage object is a bitmap of any size that can be used in other controls.

A ListImages collection is a collection of ListImage objects.

Properties and Methods

Property

Description

Count

(read-only) The total number of ListImages in the collection

Index

(read-only) An integer that uniquely identifies a ListImage in the collection.
The Index property is set by default to the order of the creation of objects in a collection. The index for the first object in a collection will always be 1.

Item (Index)

Returns a specific member of the collection (either by position or by key).
Because Item is the default property, the following lines are equivalent :
Print MyCollection(1)
Print MyCollection.Item(1)

Key

(read-write) A string that uniquely identifies a ListImage in the collection

Picture

(read-only) The ListImage bitmap itself

Method

Description

Add

Parameters: [Index], [Key], Picture

Adds a ListImage object to a ListImages collection

Index

(optional) An integer specifying the position where you want to insert the ListImage. If no index is specified, the ListImage is added to the end of the ListImages collection

Key

(optional) A unique string that identifies the ListImage object. Use this value to retrieve a specific ListImage object. An error occurs if the key is not unique

Picture

Specifies the picture to be added to the collection

You can load either bitmaps or icons into a ListImage object. To load a bitmap or icon, you can use the LoadPicture function:
Set imgX = ImageList1.ListImages.Add(,,LoadPicture("file name"))

You can also load a Picture object directly into the ListImage. For example to load a PictureBox picture into the ListImage object:
Set imgX = ImageList1.ListImages.Add(,,Picture1.Picture)

If no ListImage objects have been added to a ListImages collection, you can set the ImageHeight and ImageWidth properties before adding the first ListImage object. You can then add images of any size to the collection. However, when the ImageList control is bound to another Windows Common Control, all images you add to the collection will be displayed (in the bound Windows Common Control) at the size specified by the ImageHeight and ImageWidth properties. Once a ListImage object has been added to the collection, the ImageHeight and ImageWidth properties become read-only properties.

Clear

Removes all ListImages in the collection

ExtractIcon

Creates an icon from a bitmap in a ListImage object and returns a reference to the newly created icon. You can use the icon created with the ExtractIcon method like any other icon. For example, you can use it as a setting for the MouseIcon property.

Remove

Parameters: Index

Removes a specific ListImage. Index is an integer or string that uniquely identifies the ListImage. Use an integer to specify the value of the Index property; use a string to specify the value of the Key property.