This documentation is archived and is not being maintained.

ListBox.SelectedObjectCollection Class

Represents the collection of selected items in the ListBox.

For a list of all members of this type, see ListBox.SelectedObjectCollection Members.


[Visual Basic]
Public Class ListBox.SelectedObjectCollection
   Implements IList, ICollection, IEnumerable
public class ListBox.SelectedObjectCollection : IList, ICollection,
public __gc class ListBox.SelectedObjectCollection : public IList,
   ICollection, IEnumerable
public class ListBox.SelectedObjectCollection implements IList,
   ICollection, IEnumerable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


The ListBox.SelectedObjectCollection class stores the selected items in the ListBox. The items stored in the ListBox.SelectedObjectCollection are items contained within the ListBox.ObjectCollection class. The ListBox.ObjectCollection class stores all items displayed in the ListBox.

The following table is an example of how the ListBox.ObjectCollection stores the items of the ListBox as well as their selection states within an example ListBox.

Index Item Selection State Within the ListBox
0 object1 Unselected
1 object2 Selected
2 object3 Unselected
3 object4 Selected
4 object5 Selected

Based on the ListBox.ObjectCollection demonstrated in the previous table, the following table demonstrates how the ListBox.SelectedObjectCollection would appear.

Index Selected Item from ObjectCollection
0 object2
1 object4
2 object5

You can use the properties and methods of this class to perform a variety of tasks with the collection. The Contains method enables you to determine whether an item from the ListBox.ObjectCollection class is a member of the ListBox.SelectedObjectCollection. Once you know that the item is located within the collection, 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.


Namespace: System.Windows.Forms

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

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

See Also

ListBox.SelectedObjectCollection Members | System.Windows.Forms Namespace