ListBox.SelectedIndexCollection.IndexOf(Int32) 方法

定義

ListBox.SelectedIndexCollectionListBox.ObjectCollection 傳回指定索引在 ListBox 中的索引。Returns the index within the ListBox.SelectedIndexCollection of the specified index from the ListBox.ObjectCollection of the 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 以零起始的索引。The zero-based index from the ListBox.ObjectCollection to locate in this collection.

傳回

集合中以零起始的索引,其中 ListBox.ObjectCollection 的指定索引位於 ListBox.SelectedIndexCollection 中,否則為負一 (-1)。The zero-based index in the collection where the specified index of the ListBox.ObjectCollection was located within the ListBox.SelectedIndexCollection; otherwise, negative one (-1).

備註

一旦您知道某個專案位於集合中(使用 Contains 方法),您就可以使用 IndexOf 方法來判斷 ListBoxListBox.ObjectCollection 中特定索引位置儲存在 ListBox.SelectedIndexCollection內的位置。Once you know that an item is located within the collection (using the Contains method), you can use the IndexOf method to determine where a specific index position within the ListBox.ObjectCollection for the ListBox is stored within the ListBox.SelectedIndexCollection.

適用於

另請參閱