This documentation is archived and is not being maintained.

MenuItem.CloneMenu Method

Creates a copy of the current MenuItem.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public virtual MenuItem CloneMenu()

Return Value

Type: System.Windows.Forms.MenuItem
A MenuItem that represents the duplicated menu item.

MenuItem objects cannot be used in more than one place unless you obtain a copy of the MenuItem. You can call this method to create a copy of this menu item for use in a ContextMenu, MainMenu, or other MenuItem within your application. 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 clones a MenuItem and displays it in a ContextMenu. The example requires that a MenuItem exists in a MainMenu on a form with the name of menuItem1 and that a ContextMenu object named contextMenu1 also exists on the form.

public void CloneMyMenu()
   // Clone the menu item and add it to the collection for the shortcut menu.


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0