Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ListView::SelectedIndex Property

 

Gets or sets the index of the selected item in a ListView control.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public:
property int SelectedIndex {
	virtual int get();
	virtual void set(int value);
}

Property Value

Type: System::Int32

The zero-based index of the selected item in a ListView control. The default is -1, which indicates that no item is currently selected.

Exception Condition
ArgumentOutOfRangeException

The SelectedIndex property is set to a value less than -1.

Use the SelectedIndex property to determine the index of the currently selected item in a ListView control. You can also use this property to programmatically select an item in the control. (However, if you manually data-bind the ListView control, you might have to handle reading or setting this property manually as well.)

The following example shows how to use the SelectedIndex property to determine whether an item is selected in a ListView control. This code example is part of a larger example provided for the DeleteItem method.

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

.NET Framework
Available since 3.5
Return to top
Show:
© 2017 Microsoft