ListView.SelectedListViewItemCollection.IndexOf(ListViewItem) 方法

定義

傳回指定項目集合中的索引。

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,表示位於集合中的項目。

傳回

Int32

集合中項目以零為基底的索引。 如果項目不在集合中,則傳回值是負值 (-1)。

備註

一旦您知道專案位於選取的專案集合中, (使用 Contains 方法) ,您可以使用 IndexOf 方法來判斷專案在 中 ListView.SelectedListViewItemCollection 的位置。

適用於

另請參閱