8.15 Changing a ListView Mode

 <  Day Day Up  >  

8.15 Changing a ListView Mode

You want to programmatically change the mode of a ListView control .


Technique

You can view a ListView in one of four different modes. The View property controls the mode and you can set it using a value defined in the View enumerated data type. In the SmallIcon mode, the items are arranged in rows using small icons as specified in the SmallImageList property. An example of a ListView in small icon mode appears in Figure 8.5.

Figure 8.5. ListView control whose View property is set to SmallIcon .

graphics/08fig05.gif

The LargeIcon view is similar to the SmallIcon view with the main obvious difference being the size of the icons that appear. It should be noted that you can use the same ImageList used in the SmallImageList . The ListView simply expands each item's draw rectangle to accommodate larger images, as shown in Figure 8.6.

Figure 8.6. ListView control using the LargeIcon mode.

graphics/08fig06.gif

The List mode is similar to the SmallIcon mode except the items are arranged within a single column rather than the matrix style used in the small icon mode. Finally, the Details mode allows you to create additional columns containing extra information. Each column also contains a column header displaying a string denoting what the string in each column for each item represents. The next recipe demonstrates creating columns for a ListView .

Comments

One of the obvious powerful features of the ListView control is its ability to change the way items are visually represented to a user . In the List view, items appear in a single column similar to that of a ListBox . However, the ListView is able to alter the appearance of each individual item within this mode using different color combinations or by utilizing an ImageList .

Icon views in a ListView are similar to the default view method you see when browsing files in Windows Explorer. The items are arranged in a matrix-like fashion using a number of columns and rows. An advantage of using these modes is that you are able to display more items in a smaller space than is possible with either the List or Details view.

The Details view is the only view that takes advantage of the SubItems collection of each ListViewItem . The Details view is similar to the List view, but it allows you to create additional columns to display extra information about each item. For instance, in Windows Explorer, the Details view allows you to inspect additional file attributes such as the file's size; creation date; last modified date; and, in some instances, file-specific information, such as picture sizes for bitmaps. The next recipe demonstrates how to add columns and assign data to the subitems of each ListViewItem so that this information appears in each column.

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net