Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ebook) Visual Studio .NET Mastering Visual Basic.pdf
Скачиваний:
120
Добавлен:
17.08.2013
Размер:
15.38 Mб
Скачать

746 Chapter 16 THE TREEVIEW AND LISTVIEW CONTROLS

in this collection is a TreeNode object, which in turn may have its own Nodes collection, which is another collection of TreeNode objects. We’ll discuss these techniques in detail, but there’s something else I would like to mention briefly and get out of the way as early as possible.

The TreeView and ListView controls are commonly used along with the ImageList control. The ImageList control is a very simple control for storing images so they can be retrieved quickly and used at runtime. You populate the ImageList control with images, usually at design time, and then you recall them by an index value at runtime. Before we get into the details of the TreeView and ListView controls, a quick overview of the ImageList control is in order. The reason I present it here is that the ImageList control is used almost exclusively with the TreeView and ListView controls.

The ImageList Control

The ImageList control is a really simple control that stores a number of images used by other controls at runtime. For example, a TreeView control may use a number of icons to identify its nodes. The simplest and quickest method of preparing the images to be used with the TreeView control is to create an ImageList with icons. The ImageList control maintains a series of bitmaps in memory that the TreeView control can access very quickly at runtime. Keep in mind that the ImageList control can’t be used on its own and remains invisible at runtime.

The images stored in the ImageList control can be used for any purpose by your application, but in this book, we’ll use them in conjunction with the TreeView and ListView controls, which use them to identify their nodes and list items, respectively. So, before we start the discussion of the TreeView and ListView controls, let’s look at how to store images in an ImageList control and how to use this control in our code.

To use the ImageList control in a project, double-click its icon in the Toolbox to place an instance of the control to your project. To load images to an ImageList control, locate the Images property in the Properties window and click the button with the ellipses next to the property name. The Image Collection Editor window (Figure 16.5) will pop up, and you can load all the images you want by selecting the appropriate files. All the images should have the same dimensions—but this is not a requirement. Notice that the ImageList control doesn’t resize the images; they must have the same size as when you load them.

Figure 16.5

The Image Collection Editor

Copyright ©2002 SYBEX, Inc., Alameda, CA

www.sybex.com