Control.ControlCollection.IndexOfKey(String) Control.ControlCollection.IndexOfKey(String) Control.ControlCollection.IndexOfKey(String) Control.ControlCollection.IndexOfKey(String) Method

定义

检索指定项在集合中的第一个匹配项的索引。Retrieves the index of the first occurrence of the specified item within the collection.

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 control to search for.

返回

具有指定名称的控件在集合中的第一个匹配项的从零开始的索引。The zero-based index of the first occurrence of the control with the specified name in the collection.

注解

如果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.

密钥比较不区分大小写。The key comparison is not case-sensitive. 如果参数为null或空字符串,或者未找到具有指定键的项, IndexOfKey则返回-1。 keyIf the key parameter is null or an empty string, or an item with the specified key is not found, IndexOfKey returns -1.

Control Control.ControlCollectionName 属性Control对应于中的的键。The Name property of a Control corresponds to the key for a Control in the Control.ControlCollection.

适用于