ListBox.ObjectCollection.IndexOf 方法

返回指定的项在集合中的索引。

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

语法

声明
Public Function IndexOf ( _
    value As Object _
) As Integer
用法
Dim instance As ObjectCollection
Dim value As Object
Dim returnValue As Integer

returnValue = instance.IndexOf(value)
public int IndexOf (
    Object value
)
public:
virtual int IndexOf (
    Object^ value
) sealed
public final int IndexOf (
    Object value
)
public final function IndexOf (
    value : Object
) : int

参数

  • value
    一个对象,它表示要在集合中查找的项。

返回值

项在集合内的所在位置处的从零开始的索引;或者为负一 (-1)。

异常

异常类型 条件

ArgumentNullException

value 参数为 null。

备注

IndexOf 方法使您能够确定项在集合中的位置。若要在调用此方法前确定一个项是否位于集合内,请使用 Contains 方法。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、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

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ListBox.ObjectCollection 类
ListBox.ObjectCollection 成员
System.Windows.Forms 命名空间
Contains