ListView.ListViewItemCollection.IndexOfKey(String) ListView.ListViewItemCollection.IndexOfKey(String) ListView.ListViewItemCollection.IndexOfKey(String) ListView.ListViewItemCollection.IndexOfKey(String) Method

定义

检索具有指定键的项的索引。Retrieves the index of the item with the specified key.

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

参数

key
String String String String

要在集合中查找的项的名称。The name of the item to find in the collection.

返回

如果找到具有指定键的项,则为第一个匹配项的从零开始的索引;否则为 -1。The zero-based index of the first occurrence of the item with the specified key, if found; otherwise, -1.

注解

如果IndexOfKey连续调用,最后返回的索引将首先检查键匹配项,如果没有匹配项,则从集合的开头开始搜索。If IndexOfKey is called successively, the last returned index will be checked for a key match first, and if there is no match, the search starts at the beginning of the collection.

属性对应于中ListViewItem ListView.ListViewItemCollection的的键。 NameThe Name property corresponds to the key for a ListViewItem in the ListView.ListViewItemCollection.

密钥比较不区分大小写。The key comparison is not case-sensitive. 如果参数为null或空字符串, IndexOfKey则返回-1 key``.If the key parameter is null or an empty string, IndexOfKey returns -1.

适用于