语言

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。

适用于