Menu.MenuItemCollection.Add Method (String, MenuItem)
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
- Type: System.String
The caption of the menu item.
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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.