ComboBox.ObjectCollection ComboBox.ObjectCollection ComboBox.ObjectCollection ComboBox.ObjectCollection Class


表示 ComboBox 中项的集合。Represents the collection of items in a ComboBox.

public: ref class ComboBox::ObjectCollection : System::Collections::IList
public class ComboBox.ObjectCollection : System.Collections.IList
type ComboBox.ObjectCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class ComboBox.ObjectCollection
Implements IList


类封装中的项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(ComboBox) ComboBox.ObjectCollection(ComboBox) ComboBox.ObjectCollection(ComboBox)

初始化 ComboBox.ObjectCollection 的新实例。Initializes a new instance of ComboBox.ObjectCollection.


Count Count Count Count

获取集合中的项数。Gets the number of items in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取指示能否修改该集合的值。Gets a value indicating whether this collection can be modified.

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

检索集合中指定索引处的项。Retrieves the item at the specified index within the collection.


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

ComboBox 的项列表添加项。Adds an item to the list of items for a ComboBox.

AddRange(Object[]) AddRange(Object[]) AddRange(Object[]) AddRange(Object[])

ComboBox 的项列表添加项的数组。Adds an array of items to the list of items for a ComboBox.

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

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

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

确定指定项是否位于集合内。Determines if the specified item is located within the collection.

CopyTo(Object[], Int32) CopyTo(Object[], Int32) CopyTo(Object[], Int32) CopyTo(Object[], Int32)

将整个集合复制到现有对象的数组中,从该数组内的指定位置开始复制。Copies the entire collection into an existing array of objects 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 item collection.

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

作为默认哈希函数。Serves as the default hash function.

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

获取当前实例的 TypeGets the Type of the current instance.

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

检索指定的项在集合中的索引。Retrieves the index within the collection of the specified item.

Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object) Insert(Int32, Object)

将一项插入集合中指定索引处。Inserts an item into the collection at the specified index.

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

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

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

ComboBox 中删除指定的项。Removes the specified item from the ComboBox.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

移除 ComboBox 中指定索引处的项。Removes an item from the ComboBox at the specified index.

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

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)


ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

有关此成员的说明,请参见 CopyTo(Array, Int32)For a description of this member, see CopyTo(Array, Int32).

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

有关此成员的说明,请参见 IsSynchronizedFor a description of this member, see IsSynchronized.

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

有关此成员的说明,请参见 SyncRootFor a description of this member, see SyncRoot.

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

有关此成员的说明,请参见 Add(Object)For a description of this member, see Add(Object).

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

有关此成员的说明,请参见 IsFixedSizeFor a description of this member, see IsFixedSize.


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

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

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

根据指定类型筛选 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)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.