Udostępnij za pośrednictwem


ListView Control Overview (Windows Forms)

The Windows Forms ListView control displays a list of items with icons. You can use a list view to create a user interface like the right pane of Windows Explorer. The control has four view modes: LargeIcon, SmallIcon, List, and Details.

What You Can Do with the ListView Control

Note

An additional view mode, Tile, is only available on Windows XP and the Windows Server 2003 operating system. For more information, see How to: Enable Tile View in a Windows Forms ListView Control.

The LargeIcon mode displays large icons next to the item text; the items appear in multiple columns if the control is large enough. The SmallIcon mode is the same except that it displays small icons. The List mode displays small icons but is always in a single column. The Details mode displays items in multiple columns. For details, see How to: Add Columns to the Windows Forms ListView Control. The view mode is determined by the View property. All of the view modes can display images from image lists. For details, see How to: Display Icons for the Windows Forms ListView Control.

The following table lists some of the ListView members and the views they are valid in.

ListView member

View

Alignment property

SmallIcon or LargeIcon

AutoArrange property

SmallIcon or LargeIcon

AutoResizeColumn method

Details

Columns property

Details or Tile

DrawSubItem event

Details

FindItemWithText method

Details, List, or Tile

FindNearestItem method

SmallIcon or LargeIcon

GetItemAt method

Details or Tile

Groups property

All views except List

HeaderStyle property

Details.

InsertionMark property

LargeIcon, SmallIcon, or Tile

The key property of the ListView control is Items, which contains the items displayed by the control. The SelectedItems property contains a collection of the items currently selected in the control. The user can select multiple items, for example to drag and drop several items at a time to another control, if the MultiSelect property is set to true. The ListView control can display check boxes next to the items, if the CheckBoxes property is set to true.

The Activation property determines what type of action the user must take to activate an item in the list: the options are Standard, OneClick, and TwoClick. OneClick activation requires a single click to activate the item. TwoClick activation requires the user to double-click to activate the item; a single click changes the color of the item text. Standard activation requires the user to double-click to activate an item, but the item does not change appearance.

The ListView control also supports the visual styles and other features available on the Windows XP platform, including grouping, tile view, and insertion marks. For more information, see Windows XP Features and Windows Forms Controls.

See Also

Tasks

How to: Add and Remove Items with the Windows Forms ListView Control

How to: Add Columns to the Windows Forms ListView Control

How to: Display Icons for the Windows Forms ListView Control

How to: Display Subitems in Columns with the Windows Forms ListView Control

How to: Select an Item in the Windows Forms ListView Control

How to: Group Items in a Windows Forms ListView Control

How to: Display an Insertion Mark in a Windows Forms ListView Control

How to: Add Search Capabilities to a ListView Control

How to: Add Custom Information to a TreeView or ListView Control (Windows Forms)

How to: Create a Multipane User Interface with Windows Forms

Reference

ListView

Other Resources

ListView Control (Windows Forms)