ListView.ListViewItemCollection.IndexOf(ListViewItem) ListView.ListViewItemCollection.IndexOf(ListViewItem) ListView.ListViewItemCollection.IndexOf(ListViewItem) ListView.ListViewItemCollection.IndexOf(ListViewItem) Method

定义

返回指定的项在集合中的索引。Returns the index within the collection of the specified item.

public:
 int IndexOf(System::Windows::Forms::ListViewItem ^ item);
public int IndexOf (System.Windows.Forms.ListViewItem item);
member this.IndexOf : System.Windows.Forms.ListViewItem -> int
Public Function IndexOf (item As ListViewItem) As Integer

参数

item
ListViewItem ListViewItem ListViewItem ListViewItem

ListViewItem,表示要在集合中查找的项。A ListViewItem representing the item to locate in the collection.

返回

项在集合中的位置的从零开始的索引;如果项不在集合中,则为 -1。The zero-based index of the item's location in the collection; otherwise, -1 if the item is not located in the collection.

注解

使用IndexOf方法可以确定项在集合中的位置。The IndexOf method enables you to determine the position of an item in the collection. 若要在调用此方法之前确定集合中是否包含某一项,请Contains使用方法。To determine whether an item is contained in the collection before calling this method, use the Contains method.

适用于

另请参阅