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.

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

IndexIndex 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.SelectedObjectCollection为的成员。The 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()

返回一个表示当前对象的 string。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.

适用于