This topic has not yet been rated - Rate this topic

OleMenuCommand Class

Represents a menu command in Visual Studio.

Object
  MenuCommand
    Microsoft.VisualStudio.Shell.OleMenuCommand

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)
[ComVisibleAttribute(true)]
public class OleMenuCommand : MenuCommand, 
	IOleMenuCommand, IMenuCommandInvokeEx

The OleMenuCommand type exposes the following members.

  NameDescription
Public methodOleMenuCommand(EventHandler, CommandID)Initializes a new instance of OleMenuCommand for the specified command.
Public methodOleMenuCommand(EventHandler, CommandID, String)Initializes a new instance of OleMenuCommand for the specified command.
Public methodOleMenuCommand(EventHandler, EventHandler, CommandID)Initializes a new instance of OleMenuCommand for the specified command with the specified invocation and status handlers.
Public methodOleMenuCommand(EventHandler, EventHandler, CommandID, String)Initializes a new instance of OleMenuCommand for the specified command with the specified invocation and status handlers.
Public methodOleMenuCommand(EventHandler, EventHandler, EventHandler, CommandID)Initializes a new instance of OleMenuCommand for the specified command with the specified pre-QueryStatus, invocation, and status handlers.
Public methodOleMenuCommand(EventHandler, EventHandler, EventHandler, CommandID, String)Initializes a new instance of OleMenuCommand for the specified command with the specified pre-QueryStatus, invocation, and status handlers.
Top
  NameDescription
Public propertyCheckedGets or sets a value indicating whether this menu item is checked. (Inherited from MenuCommand.)
Public propertyCommandIDGets the CommandID associated with this menu command. (Inherited from MenuCommand.)
Public propertyEnabledGets a value indicating whether this menu item is available. (Inherited from MenuCommand.)
Public propertyMatchedCommandIdGets or sets the command ID.
Public propertyOleStatusGets the OLE command status code for this menu item. (Overrides MenuCommand.OleStatus.)
Public propertyParametersDescriptionGets or sets the description of the parameters of the command.
Public propertyPropertiesGets the public properties associated with the MenuCommand. (Inherited from MenuCommand.)
Public propertySupportedGets or sets a value indicating whether this menu item is supported. (Inherited from MenuCommand.)
Public propertyTextGets or sets the text for the command.
Public propertyVisibleGets or sets a value indicating whether this menu item is visible. (Inherited from MenuCommand.)
Top
  NameDescription
Public methodDynamicItemMatchAllows a dynamic item command to match the subsequent items in its list.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInvokeInvokes the command. (Inherited from MenuCommand.)
Public methodInvoke(Object)Executes the command. (Overrides MenuCommand.Invoke(Object).)
Public methodInvoke(Object, IntPtr)Executes the command.
Public methodInvoke(Object, IntPtr, OLECMDEXECOPT)Executes the command with the specified parameters and execution options.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnCommandChangedRaises the CommandChanged event. (Inherited from MenuCommand.)
Public methodToStringReturns a string representation of this menu command. (Inherited from MenuCommand.)
Top
  NameDescription
Public eventBeforeQueryStatusCalled when a client requests the status of the command.
Public eventCommandChangedOccurs when the menu command changes. (Inherited from MenuCommand.)
Top

This class implements IOleMenuCommand and IOleCommandInvokeEx, and derives from MenuCommand. You can use either MenuCommand or OleMenuCommand when you add a command in a Visual Studio extension. However, if the command is added dynamically, it makes more sense to use OleMenuCommand, in order to implement the BeforeQueryStatus handler.

You can find examples of this class in the following walkthroughs:

  1. How to: Create and Handle Commands in VSPackages (C#)

  2. How to: Change the Text of a Menu Command

  3. How to: Create Menus, SubMenus, and Shortcut Menus

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.