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

要擷取索引的影像之索引鍵。

傳回

Int32

如果找到的話,則為集合中具有指定索引鍵的影像,其第一個相符項目之以零起始的索引,否則為 -1。

備註

如果 IndexOfKey 連續呼叫 ,則會先檢查最後傳回的索引鍵是否相符,如果沒有相符專案,搜尋就會從集合的開頭開始。

影像的名稱會對應至 中的 ImageList.ImageCollection 索引鍵。 索引鍵比較不區分大小寫。 key如果 參數為 null 或空字串,方法會 IndexOfKey 傳回 -1。

適用於