Uređivanje

Dijeli putem


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.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)

Initializes a new instance of the ListBox.SelectedObjectCollection class.

Properties

Count

Gets the number of items in the collection.

IsReadOnly

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

Item[Int32]

Gets the item at the specified index within the collection.

Methods

Add(Object)

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

Clear()

Removes all items from the collection of selected items.

Contains(Object)

Determines whether the specified item is located within the collection.

CopyTo(Array, Int32)

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

Equals(Object)

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

(Inherited from Object)
GetEnumerator()

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

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(Object)

Returns the index within the collection of the specified item.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(Object)

Removes the specified object from the collection of selected items.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.IsSynchronized

For a description of this member, see IsSynchronized.

ICollection.SyncRoot

For a description of this member, see SyncRoot.

IList.Add(Object)

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

IList.Clear()

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

IList.Insert(Int32, Object)

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

IList.IsFixedSize

For a description of this member, see IsFixedSize.

IList.Remove(Object)

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

IList.RemoveAt(Int32)

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

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to