ToolStripItemCollection.IndexOfKey(String) ToolStripItemCollection.IndexOfKey(String) ToolStripItemCollection.IndexOfKey(String) ToolStripItemCollection.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

要搜索的 ToolStripItem 的名称。The name of the ToolStripItem to search for.

返回

如果找到 key 参数指定的 ToolStripItem 的第一个匹配项,则为表示该项位置的从零开始的索引值;如果未找到,则为 -1。A zero-based index value that represents the position of the first occurrence of the ToolStripItem specified by the key parameter, if found; otherwise, -1.

注解

参数值与ToolStripItem.Name属性相对应。 keyThe key parameter value corresponds to the ToolStripItem.Name property.

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

适用于