Export (0) Print
Expand All

ListView.SelectedListViewItemCollection.IndexOf Method

Returns the index within the collection of the specified item.

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

public int IndexOf(
	ListViewItem item
)

Parameters

item
Type: System.Windows.Forms.ListViewItem

A ListViewItem representing the item to locate in the collection.

Return Value

Type: System.Int32
The zero-based index of the item in the collection. If the item is not located in the collection, the return value is negative one (-1).

Once you know that an item is in the selected item collection (using the Contains method), you can use the IndexOf method to determine the position of the item in the ListView.SelectedListViewItemCollection.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft