ListBox.SelectedIndexCollection.IndexOf(Int32) 方法

定義

ListBox.SelectedIndexCollectionListBox.ObjectCollection 傳回指定索引在 ListBox 中的索引。

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

要放置在這個集合中的 ListBox.ObjectCollection 以零起始的索引。

傳回

Int32

集合中以零起始的索引,其中 ListBox.ObjectCollection 的指定索引位於 ListBox.SelectedIndexCollection 中,否則為負一 (-1)。

備註

一旦您知道專案位於集合內, (使用 Contains 方法) ,您就可以使用 IndexOf 方法來判斷 中的特定索引位置 ListBox.ObjectCollection ListBox 儲存在 內 ListBox.SelectedIndexCollection

適用於

另請參閱