![]() ![]() | ||
You can add list views to a Windows form just like any other control—just drag it from the toolbox to the form at design time. To add items to a list box, open the Items property in the Properties window, which displays the ListViewItem Collection Editor that you see in Figure 10.14. This editor is much like the TreeNode editor (see "Creating Tree Views" in this chapter), and works in the same way—to add a new list view item, click Add, to delete one, click Remove. You can set the various properties of list view items in this editor, such as the item's text, its image index in a list view, and so on.
As discussed in the In Depth section, there are four views you can use in a list view. You select one by assigning a value (View.LargeIcon, View.SmallIcon, View.List, or View.Details) to the list view's View property:
Large icon mode—displays large icons (large icons are 32×32 pixels) next to the item text.
Small icon mode—is the same as the large icon mode except that it displays items using small icons (small icons are 16×16 pixels).
List mode—displays small icons, and always in one column.
Report mode (also called the details mode)—displays items in multiple columns, displaying column headers and fields.
You also can create list views in code—take a look at the next topic to see how.
![]() ![]() | ||