This documentation is archived and is not being maintained.

ListBox.SelectedIndexCollection.IndexOf Method

Returns the index within the ListBox.SelectedIndexCollection of the specified index from the ListBox.ObjectCollection of the ListBox.

[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 ListBox.ObjectCollection to locate in this collection.

Return Value

The zero-based index in the collection where the specified index of the ListBox.ObjectCollection was located within the ListBox.SelectedIndexCollection; otherwise, negative one (-1).


Once you know that an item is located within the collection (using the Contains method), you can use the IndexOf method to determine where a specific index position within the ListBox.ObjectCollection for the ListBox is stored within the ListBox.SelectedIndexCollection.


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

See Also

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