Partilhar via


ImageList Component Overview (Windows Forms)

The Windows Forms ImageList component is used to store images, which can then be displayed by controls. An image list allows you to write code for a single, consistent catalog of images. For example, you can rotate images displayed by a Button control simply by changing the button's ImageIndex or ImageKey property. You can also associate the same image list with multiple controls. For example, if you are using both a ListView control and a TreeView control to display the same list of files, changing a file's icon in the image list will cause the new icon to appear in both views.

Using ImageList with Controls

You can use an image list with any control that has an ImageList property — or in the case of the ListView control, SmallImageList and LargeImageList properties. The controls that can be associated with an image list include: the ListView, TreeView, ToolBar, TabControl, Button, CheckBox, RadioButton, and Label controls. To associate the image list with a control, set the control's ImageList property to the name of the ImageList component.

Key Properties

The key property of the ImageList component is Images, which contains the pictures to be used by the associated control. Each individual image can be accessed by its index value or by its key. The ColorDepth property determines the number of colors that the images are rendered with. The images will all be displayed at the same size, set by the ImageSize property. Images that are larger will be scaled to fit.

If you are using Visual Studio 2005, you have access to a large library of standard images that you can use in your applications. Visual Studio 2005 Image Library
Visual Studio Image Library

See Also

Tasks

How to: Add or Remove Images with the Windows Forms ImageList Component

Reference

ImageList