語言

ImageList.ImageCollection.IndexOfKey(String) 方法

定義

決定集合中以指定鍵首次出現影像的索引。

public:
 int IndexOfKey(System::String ^ key);
public int IndexOfKey(string key);
member this.IndexOfKey : string -> int
Public Function IndexOfKey (key As String) As Integer

參數

key
String

圖片的索引鍵。

傳回

若在集合中首次出現具有指定鍵的影像,該索引為零為基礎;否則,為負1。

備註

若 IndexOfKey 連續呼叫,則會先檢查最後回傳的索引是否有鍵符,若無匹配,則從集合開始搜尋。

影像的名稱對應於其在 ImageList.ImageCollection中的鍵。 關鍵比較並不區分大小寫。 若 key 參數為 null 或 為空字串,則方法 IndexOfKey 回傳 -1。

適用於