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

VB ImageList - ImageList Control in Visual Basic

The ImageList is a control that enables you to store graphic images in an application. Other controls can then use the ImageList as a central repository for the images that they will use. Both bitmaps (*.bmp files) and icons (*.ico files) can be stored in the ImageList control. At runtime the ImageList is invisible, just like a Timer or a CommonDialog control, so you can place it anywhere on a form without interfering with the user interface.

After an ImageList control has been added to a form, images can be added to the control at design time through the Custom Properties dialog box. The first tab of the dialog box, as shown in Figure 4.2, enables you to change general properties of the ImageList. On this tab, you can select the style and size of a graphic that will be included in the ImageList. Three of the resolutions, 16´16, 32´32, and 48´48, refer to the resolution of icon files. The Custom option lets you include bitmap images in the ImageList as well as icon images. You do not need to choose a resolution, height, and width for the ImageList. As soon as you add an image to the control, Visual Basic automatically determines the properties for you. After you have placed an image in the ImageList, you cannot change the resolution property. It is locked for as long as there is an image in the ImageList control.

The General tab of the Property Pages dialog box for the ImageList control.
FIGURE 4.2 The General tab of the Property Pages dialog box for the ImageList control.

The list of images contained in the ImageList control can be managed through the Images tab of the Property Pages dialog box, as shown in Figure 4.3. This tab enables you to add and remove images from the control as well as set additional information about each image. The Index of each image is assigned by Visual Basic. The Index starts at 1 for the first image and increments by 1 for each additional image.

The Images tab of the Property Pages dialog box for the ImageList control.
FIGURE 4.3 The Images tab of the Property Pages dialog box for the ImageList control.

You can use the Key property to refer to an image in the ImageList's collection of images. The Key property is a string value that you can use in place of the Index property to refer to an image in the list.

The easiest way to add images to the ImageList is to use the Images tab at design time. Just click on the Insert Picture button, and you can browse for the *.ico and *.bmp files that you want to add to the control.

After you have added images to the ImageList control, they are available for your application to use in other controls. You can load images into PictureBoxes and Image controls from the ImageList. The images can also be used by the other controls discussed later in this chapter, such as the ToolBar and ListView controls.

Although you can add all the images you may need in your application to the ImageList at design time, there are times when you will have to manipulate these images at runtime. This can be done through the ListImages Collection of the ImageList control. The ListImages Collection contains ListImage objects.

See Also


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved