ListBox.SelectedObjectCollection.IndexOf Method (Object)


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(
	object selectedObject


Type: System.Object

An object representing the item to locate in the collection.

Return Value

Type: System.Int32

The zero-based index of the item in the collection; otherwise, -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 item within the ListBox.ObjectCollection for the ListBox is stored within the ListBox.SelectedObjectCollection.

.NET Framework
Available since 1.1
Return to top