Menu.MenuItemCollection.Find(String, Boolean) Method

Definition

Finds the items with the specified key, optionally searching the submenu items.

C#
public System.Windows.Forms.MenuItem[] Find(string key, bool searchAllChildren);

Parameters

key
String

The name of the menu item to search for.

searchAllChildren
Boolean

true to search child menu items; otherwise, false.

Returns

An array of MenuItem objects whose Name property matches the specified key.

Exceptions

key is null or an empty string.

Remarks

The key comparison is not case-sensitive. If the key parameter is null or an empty string, or there are no matches, Find returns an empty array.

The Name property corresponds to the key for a MenuItem in the Menu.MenuItemCollection.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10