ListBox.SelectedObjectCollection 類別

定義

表示 ListBox 中所選項目的集合。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
繼承
ListBox.SelectedObjectCollection
實作

備註

類別會將選取的專案儲存ListBox在中。 ListBox.SelectedObjectCollectionThe ListBox.SelectedObjectCollection class stores the selected items in the ListBox. 儲存在中ListBox.SelectedObjectCollection的專案是包含在ListBox.ObjectCollection類別內的專案。The items stored in the ListBox.SelectedObjectCollection are items contained within the ListBox.ObjectCollection class. 類別會儲存顯示在中的ListBox所有專案。 ListBox.ObjectCollectionThe ListBox.ObjectCollection class stores all items displayed in the ListBox.

下表是一個範例,說明如何在ListBox.ObjectCollection範例ListBox中儲存的專案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
00 object1object1 未選取Unselected
11 object2object2 已選取Selected
22 object3object3 未選取Unselected
33 object4object4 已選取Selected
44 object5object5 已選取Selected

根據上表ListBox.ObjectCollection中所示範的,下表將示範ListBox.SelectedObjectCollection如何顯示。Based on the ListBox.ObjectCollection demonstrated in the previous table, the following table demonstrates how the ListBox.SelectedObjectCollection would appear.

索引Index 從 ObjectCollection 選取的專案Selected item from ObjectCollection
00 object2object2
11 object4object4
22 object5object5

您可以使用這個類別的屬性和方法,利用集合來執行各種工作。You can use the properties and methods of this class to perform a variety of tasks with the collection. 方法可讓您判斷ListBox.ObjectCollection類別中的專案是否ListBox.SelectedObjectCollection為的成員。 ContainsThe Contains method enables you to determine whether an item from the ListBox.ObjectCollection class is a member of the ListBox.SelectedObjectCollection. 一旦您知道專案位於集合中, IndexOf您就可以使用方法來判斷ListBox.ObjectCollectionListBox的特定專案儲存在中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.

建構函式

ListBox.SelectedObjectCollection(ListBox)

初始化 ListBox.SelectedObjectCollection 類別的新執行個體。Initializes a new instance of the ListBox.SelectedObjectCollection class.

屬性

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.

方法

Add(Object)

將項目加入 ListBox 的選取項目清單中。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.

(繼承來源 Object)
GetEnumerator()

傳回列舉值,其可用來在選取項目集合中重複。Returns an enumerator that can be used to iterate through the selected item collection.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(Object)

傳回指定項目集合中的索引。Returns the index within the collection of the specified item.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(Object)

從選取項目的集合中移除指定的物件。Removes the specified object from the collection of selected items.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.IsSynchronized

如需這個成員的說明,請參閱 IsSynchronizedFor a description of this member, see IsSynchronized.

ICollection.SyncRoot

如需這個成員的說明,請參閱 SyncRootFor a description of this member, see SyncRoot.

IList.Add(Object)

如需這個成員的說明,請參閱 Add(Object)For a description of this member, see Add(Object).

IList.Clear()

如需這個成員的說明,請參閱 Clear()For a description of this member, see Clear().

IList.Insert(Int32, Object)

如需這個成員的說明,請參閱 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize

如需這個成員的說明,請參閱 IsFixedSizeFor a description of this member, see IsFixedSize.

IList.Remove(Object)

如需這個成員的說明,請參閱 Remove(Object)For a description of this member, see Remove(Object).

IList.RemoveAt(Int32)

如需這個成員的說明,請參閱 RemoveAt(Int32)For a description of this member, see RemoveAt(Int32).

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於