System.ComponentModel.Design.IMenuCommandService.AddCommand Method

Adds the specified standard menu command to the menu.

Syntax

public void AddCommand (MenuCommand command)

Parameters

command
The System.ComponentModel.Design.MenuCommand to add.

Remarks

The System.Windows.Forms.Design.MenuCommands and System.ComponentModel.Design.StandardCommands enumerations contain System.ComponentModel.Design.CommandID identifiers for predefined standard commands and menu commands that are already associated with a location on a particular menu.

Note:

An attempt to add a menu command with an already existing System.ComponentModel.Design.CommandID will throw an InvalidOperationException. When adding a menu command, be sure to check that it is not already on a menu using the IMenuCommandService.FindCommand(CommandID) method, or use exception handling wisely.

You can attach an event handler to a predefined menu command with the following procedure:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

Requirements

Namespace: System.ComponentModel.Design
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0