Selected Property

ListViewItem.Selected Property


Gets or sets a value indicating whether the item is selected.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member Selected : bool with get, set

Property Value

Type: System.Boolean

true if the item is selected; otherwise, false.

If the MultiSelect property of the ListView control the item is contained in is set to true, setting the value of this property adds or removes the item from the set of selected items. If the MultiSelect property is set to false, setting the value of this property to select an item automatically cancels the selection for any other items in the ListView control. You can use this property to determine if an item is selected or to select an item at run time. You can access all items that are selected in a ListView control by using the ListView.SelectedItems property.


Items appear selected only when the ListView control has focus. To select items in response to a user action such as a button click, be sure to call the Focus method in addition to setting this property.

The following code example demonstrates how to use the ListView.Clear and Selected members. To run the example, place the following code in a form containing a ListView named ListView1 and a Button, located toward the bottom of the form, named Button1. Call the InitializeListView method from the form's constructor or Load event-handling method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
© 2016 Microsoft