MenuItem.CloneMenu Method (MenuItem)
Creates a copy of the specified MenuItem.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Call this method to create copies of menu items that you have already created for use in a shortcut menu or another menu structure within your application. This version of CloneMenu allows you to specify a specific MenuItem to copy instead of the menu item that is calling the method. You can use this method to initialize a new MenuItem object with a copy of another MenuItem. When a menu item is cloned, any event handlers specified in the original menu item will continue to function in the cloned version of the menu item. For example, if you created a MenuItem and connected its Click event to an event handler. When the menu item is cloned, the cloned menu item will call the same event handler.
The following code example initializes a new MenuItem with a copy of an existing MenuItem that is used in a MainMenu on a form. The code then adds the cloned MenuItem to a ContextMenu on the form. This example requires that a MenuItem is already created and named menuItem1 and that a ContextMenu control has been created and named contextMenu1.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.