Export (0) Print
Expand All

ListView.SelectedIndexCollection.IndexOf Method

Returns the index within the ListView.SelectedIndexCollection of the specified index from the ListView.ListViewItemCollection of the list view control.

[Visual Basic]
Public Function IndexOf( _
   ByVal selectedIndex As Integer _
) As Integer
public int IndexOf(
 int selectedIndex
public: int IndexOf(
 int selectedIndex
public function IndexOf(
   selectedIndex : int
) : int;


The zero-based index from the ListView.ListViewItemCollection to locate in the collection.

Return Value

The zero-based index in the collection where the specified index of the ListView.ListViewItemCollection is located within the ListView.SelectedIndexCollection. If the index is not located in the collection, the return value is negative one (-1).


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


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ListView.SelectedIndexCollection Class | ListView.SelectedIndexCollection Members | System.Windows.Forms Namespace | Contains

© 2014 Microsoft