Saturday, September 27, 2008

Using the ListView Control

The ListView control displays lists of information to a user. As with the TreeView control, Windows Explorer provides an example of the ListView control. The left side of Windows Explorer contains a tree of all the directories on a drive. The right side contains a list of items within a directory. To get an idea of the ways in which a ListView control can be used, you just need to look at the way a list of files appears and behaves in Windows Explorer (see Figure 4.6).


FIGURE 4.6. Example of a ListView in Windows Explorer showing large icons

Objects can be displayed in one of four ways with the ListView. You can use either large or small icons to represent each item in the list, along with accompanying text information, where multiple items can appear on a single row. You can also display items in a list with one item per line. Finally you can how items as a columnar report in the ListView control with one item appearing on each line and sub-item information displaying in additional columns in the control, as shown in Figure 4.7.

Example of a ListView in Windows Explorer showing the report style.
FIGURE 4.7. Example of a ListView in Windows Explorer showing the report style.

As you learn about the ListView, you will see similarities to the TreeView control. The behavior and appearance of the two controls can be manipulated in many of the same ways. The major difference that you will notice is that objects in a ListView are not related to each other, as are objects in a TreeView.

No comments: