ListBox.SelectedObjectCollection ListBox.SelectedObjectCollection ListBox.SelectedObjectCollection ListBox.SelectedObjectCollection Class

Definition

Represents the collection of selected items in the ListBox.

public: ref class ListBox::SelectedObjectCollection : System::Collections::IList
public class ListBox.SelectedObjectCollection : System.Collections.IList
type ListBox.SelectedObjectCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ListBox.SelectedObjectCollection
Implements IList
Inheritance
ListBox.SelectedObjectCollectionListBox.SelectedObjectCollectionListBox.SelectedObjectCollectionListBox.SelectedObjectCollection
Implements

Remarks

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.

Constructors

ListBox.SelectedObjectCollection(ListBox) ListBox.SelectedObjectCollection(ListBox) ListBox.SelectedObjectCollection(ListBox) ListBox.SelectedObjectCollection(ListBox)

Initializes a new instance of the ListBox.SelectedObjectCollection class.

Properties

Count Count Count Count

Gets the number of items in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

Gets a value indicating whether the collection is read-only.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

Gets the item at the specified index within the collection.

Methods

Add(Object) Add(Object) Add(Object) Add(Object)

Adds an item to the list of selected items for a ListBox.

Clear() Clear() Clear() Clear()

Removes all items from the collection of selected items.

Contains(Object) Contains(Object) Contains(Object) Contains(Object)

Determines whether the specified item is located within the collection.

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

Copies the entire collection into an existing array at a specified location within the array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that can be used to iterate through the selected item collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(Object) IndexOf(Object) IndexOf(Object) IndexOf(Object)

Returns the index within the collection of the specified item.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(Object) Remove(Object) Remove(Object) Remove(Object)

Removes the specified object from the collection of selected items.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

For a description of this member, see IsSynchronized.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

For a description of this member, see SyncRoot.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

For a description of this member, see Add(Object).

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

For a description of this member, see Clear().

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

For a description of this member, see IsFixedSize.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

For a description of this member, see Remove(Object).

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

For a description of this member, see RemoveAt(Int32).

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to