Share via


ListView.SelectedIndexCollection.IndexOf(Int32) 方法

定義

ListView.SelectedIndexCollection 控制項的 ListView.ListViewItemCollection 傳回在所指定索引之 ListView 中的索引。

public:
 int IndexOf(int selectedIndex);
public int IndexOf (int selectedIndex);
member this.IndexOf : int -> int
Public Function IndexOf (selectedIndex As Integer) As Integer

參數

selectedIndex
Int32

要放置在集合中之 ListView.ListViewItemCollection 以零起始的索引。

傳回

Int32

如果所指定的 ListView.ListViewItemCollection 索引位於 ListView.SelectedIndexCollection 之中,則為集合中以零起始的索引,但如果索引不在集合中,則為 -1。

備註

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

適用於

另請參閱