ListView.CheckedIndexCollection 类

表示包含列表视图控件中选中项的索引的集合。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Class CheckedIndexCollection
    Implements IList, ICollection, IEnumerable
用法
Dim instance As CheckedIndexCollection
public class CheckedIndexCollection : IList, ICollection, IEnumerable
public ref class CheckedIndexCollection : IList, ICollection, IEnumerable
public class CheckedIndexCollection implements IList, ICollection, 
    IEnumerable
public class CheckedIndexCollection implements IList, ICollection, 
    IEnumerable

备注

ListView.CheckedIndexCollection 存储了 ListView 控件中选中项的索引。只有将 ListView 控件的 CheckBoxes 属性设置为 true,才能通过复选框选中项。ListView.CheckedIndexCollection 中存储的索引是 ListView.ListViewItemCollection 内的索引位置。ListView.ListViewItemCollection 存储在 ListView 控件中显示的所有项。

下表是 ListView.ListViewItemCollection 如何存储 ListView 的项以及它们在示例 ListView 控件中的选中状态的示例。

索引

ListView 中的选中状态

0

Item1

未选中

1

Item2

已选中

2

Item3

未选中

3

Item4

已选中

4

Item5

已选中

基于前一个表中的 ListView.ListViewItemCollection 示例,下表说明 ListView.CheckedIndexCollection 将如何显示。

索引

ListViewItemCollection 中选定项的索引

0

1

1

3

2

4

可以使用此类的属性和方法对集合执行各种任务。Contains 方法使您能够确定 ListView.ListViewItemCollection 的索引位置是否是存储在 ListView.CheckedIndexCollection 中的索引之一。知道项位于该集合中后,可以使用 IndexOf 方法确定该索引在 ListView.CheckedIndexCollection 中的位置。

继承层次结构

System.Object
  System.Windows.Forms.ListView.CheckedIndexCollection

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

ListView.CheckedIndexCollection 成员
System.Windows.Forms 命名空间
ListView.ListViewItemCollection