ComboBox.ObjectCollection 類別

定義

代表 ComboBox 中項目的集合。Represents the collection of items in a ComboBox.

public: ref class ComboBox::ObjectCollection : System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class ComboBox.ObjectCollection : System.Collections.IList
type ComboBox.ObjectCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ComboBox.ObjectCollection
Implements IList
繼承
ComboBox.ObjectCollection
屬性
實作

備註

類別會封裝ComboBox中的專案。 System.Windows.Forms.ComboBox.ObjectCollectionThe System.Windows.Forms.ComboBox.ObjectCollection class encapsulates the items in the ComboBox. 下拉式方塊的物件集合可以用來管理許多類型的物件,包括字串、影像和自訂商務物件。The object collection of a combo box can be used to manage many types of objects, including strings, images, and custom business objects.

您可以透過數種方式將專案新增至集合。You can add items to the collection in several ways. Add方法會將一個物件加入至集合。The Add method adds one object to the collection. 若要將多個物件加入至集合,最好是建立專案的陣列,並使用AddRange方法指派。To add a number of objects to the collection, it is best to create an array of items and assign with the AddRange method. 若要在集合內的特定位置插入物件,您可以使用Insert方法。To insert an object at a specific location within the collection, you can use the Insert method. 若要移除集合中已知索引處的專案,您可以使用Remove方法RemoveAt或方法。To remove items at a known index in the collection you can use either the Remove method or the RemoveAt method. Clear方法會從集合中移除所有專案。The Clear method removes all the items from the collection.

除了用於加入和移除專案的方法和屬性之外, System.Windows.Forms.ComboBox.ObjectCollection也提供方法來尋找集合內的專案。In addition to methods and properties for adding and removing items, the System.Windows.Forms.ComboBox.ObjectCollection also provides methods to find items within the collection. Contains方法可讓您判斷物件是否為集合的成員。The Contains method enables you to determine if an object is a member of the collection. 一旦您知道專案位於集合中,您就可以使用IndexOf方法來判斷專案在集合中的位置。Once you know that the item is located within the collection, you can use the IndexOf method to determine where the item is located within the collection.

建構函式

ComboBox.ObjectCollection(ComboBox)

初始化 ComboBox.ObjectCollection 的新執行個體。Initializes a new instance of ComboBox.ObjectCollection.

屬性

Count

取得集合中的項目數目。Gets the number of items in the collection.

IsReadOnly

取得值,指出是否可以修改這個集合。Gets a value indicating whether this collection can be modified.

Item[Int32]

擷取集合內指定索引處的項目。Retrieves the item at the specified index within the collection.

方法

Add(Object)

將項目加入至 ComboBox 的項目清單。Adds an item to the list of items for a ComboBox.

AddRange(Object[])

將項目陣列加入至 ComboBox 項目清單中。Adds an array of items to the list of items for a ComboBox.

Clear()

ComboBox 中移除所有項目。Removes all items from the ComboBox.

Contains(Object)

判斷指定項目是否位於集合內。Determines if the specified item is located within the collection.

CopyTo(Object[], Int32)

將整個集合複製到陣列中,指定位置的現有物件陣列中。Copies the entire collection into an existing array of objects 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 item collection.

GetHashCode()

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

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
IndexOf(Object)

擷取指定項目集合內的索引。Retrieves the index within the collection of the specified item.

Insert(Int32, Object)

將項目插入至索引中的指定索引處。Inserts an item into the collection at the specified index.

MemberwiseClone()

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

(繼承來源 Object)
Remove(Object)

ComboBox 移除指定的項目。Removes the specified item from the ComboBox.

RemoveAt(Int32)

將項目從 ComboBox 的指定索引處移除。Removes an item from the ComboBox at the specified index.

ToString()

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

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

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

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

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

擴充方法

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.

適用於