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

定义

表示 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.SelectedObjectCollectionListBox.SelectedObjectCollectionListBox.SelectedObjectCollectionListBox.SelectedObjectCollection
实现

注解

ListBox.SelectedObjectCollection类存储中的选定的项ListBoxThe 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.ObjectCollection类存储中显示的所有项目ListBoxThe ListBox.ObjectCollection class stores all items displayed in the ListBox.

下表是举例说明如何ListBox.ObjectCollection中存储的项ListBox示例中其所选内容状态以及ListBoxThe 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. Contains方法使您能够确定的某个项是否ListBox.ObjectCollection类是的成员ListBox.SelectedObjectCollectionThe Contains method enables you to determine whether an item from the ListBox.ObjectCollection class is a member of the ListBox.SelectedObjectCollection. 一旦您知道项位于集合内,就可以使用IndexOf方法,以确定其中中的特定项ListBox.ObjectCollection有关ListBox存储在ListBox.SelectedObjectCollectionOnce 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(ListBox) ListBox.SelectedObjectCollection(ListBox) ListBox.SelectedObjectCollection(ListBox)

初始化 ListBox.SelectedObjectCollection 类的新实例。Initializes a new instance of the ListBox.SelectedObjectCollection class.

属性

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.

方法

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

将项添加到 ListBox 的选定项的列表。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()

获取当前实例的 TypeGets 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()

创建当前 Object 的浅表副本。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)

显式界面实现

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.Clear() IList.Clear() IList.Clear() IList.Clear()

有关此成员的说明,请参见 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)

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

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

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

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

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

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

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

扩展方法

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)

将转换IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

适用于