O'Reilly logo

.NET Windows Forms in a Nutshell by Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

ListView

Synopsis

This control wraps the ubiquitous and multifunctional Win32 ListView common control. You will be very familiar with this from the Windows Explorer icon, list, and details views.

To choose the general appearance of the control, you can use the View property, switching between two icon views (View.LargeIcon and View.SmallIcon), the basic View.List and the View.Details report format.

To control what is actually displayed in the list, you can add or remove ListViewItem objects from the Items list. See the ListViewItem class for more information about this.

In all views, you can choose the item Activation style (see ItemActivation for more details).

You can also determine whether CheckBoxes appear next to the items. To find out which items are checked, you can refer to the CheckedIndices or CheckedItems properties. Similarly, the selected items can be retrieved through the SelectedIndices and SelectedItems properties. The item that currently has the focus can be obtained through the FocusedItem property. You can enable or disable multiple selection with the MultiSelect property.

Items can be selected automatically just by hovering over them. The HoverSelection property controls this.

By default, the selection will not be rendered (but still maintained) when the control loses the focus. You can set HideSelection to false if you want the selection to be visible all the time.

Items can be sorted in the list by calling the Sort() method. To specify how the items should be sorted ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required