Menu::MenuItemCollection::Add Method (String^, array<MenuItem^>^)
Adds a new MenuItem to the end of this menu with the specified caption, Click event handler, and items.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- caption
-
Type:
System::String^
The caption of the menu item.
- items
-
Type:
array<System.Windows.Forms::MenuItem^>^
An array of MenuItem objects that this MenuItem will contain.
Return Value
Type: System.Windows.Forms::MenuItem^A MenuItem that represents the menu item being added to the collection.
A MenuItem can only be contained in one menu at a time, and cannot be added more than once to the same menu. To reuse a MenuItem in more than one menu, use the CloneMenu method of the MenuItem class. To remove a MenuItem that you have previously added, use the Remove method.
This version of the Add method allows you to specify a caption for the menu item and a delegate that will handle its Click event. You can use this version of the Add method if your application already has an event handler to handle the Click event. This version of the method also allows you to specify an array of previously created MenuItem objects that you want to add to the collection. You can use this feature to reuse existing MenuItem objects that have been cloned using the CloneMenu method. If the items parameter is not empty or null, the MenuItem being added to the collection will contain submenu items.
Available since 1.1
