VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 4

ImageList Control - Add and Remove Methods (Visual Basic 6)

You can use the Add method of the ListImages Collection to add images to the ImageList at runtime. The syntax for Add is as follows:

ImageList1.ListImages.Add([index], [key], picture)

Here ImageList1 is the name of the ImageList control on your form. Index and Key are optional parameters. If Index is specified, it will be the location at which the image is loaded into the ListImages Collection. If Index is omitted, the new image will be inserted at the end of the collection. Key is a string value that you can use to refer to an image in the list without knowing its index value. For example if an image were added as follows:

ImageList1.ListImages.Add(, "folder icon", LoadPicture("folder.ico"))

you might not know the index value of the new image, but you could still refer to it in this way:

Picture1.Picture = ImageList1.ListImages("folder icon").Picture

Using the ListImages key makes your code more readable than if you refer to images with the Index property.

You can remove a ListImage from the ListImages Collection with the Remove method. You can use Remove either by specifying the index of the image:

ImageList1.ListImages.Remove 1

or by providing the image's key value:

ImageList1.ListImages.Remove "key value"

Related topics on ImageList Control


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved