Control::ControlCollection::IndexOfKey Method (String^)
.NET Framework (current version)
Retrieves the index of the first occurrence of the specified item within the collection.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- key
-
Type:
System::String^
The name of the control to search for.
Return Value
Type: System::Int32The zero-based index of the first occurrence of the control with the specified name in the collection.
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. If the key parameter is null or an empty string, or an item with the specified key is not found, IndexOfKey returns -1.
The Name property of a Control corresponds to the key for a Control in the Control::ControlCollection.
.NET Framework
Available since 2.0
Available since 2.0
Show: