StandardCommands Class
Defines identifiers for the standard set of commands that are available to most applications.
For a list of all members of this type, see StandardCommands Members.
System.Object
System.ComponentModel.Design.StandardCommands
System.Windows.Forms.Design.MenuCommands
[Visual Basic] Public Class StandardCommands [C#] public class StandardCommands [C++] public __gc class StandardCommands [JScript] public class StandardCommands
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
This class defines CommandID identifiers for standard commands that are available to designers.
To add a command from StandardCommands to a designer menu, you must call the AddCommand of an IMenuCommandService object and add a MenuCommand that contains a CommandID from StandardCommands.
Example
[Visual Basic, C#, C++] This example illustrates how to add a member of StandardCommands to a MenuCommand object and how to add the MenuCommand object to a IMenuCommandService object.
[Visual Basic] ' This example illustrates how to add a command of type StandardCommand to a ' service of type IMenuCommandService. It defines a class that is a designer ' to a component, called CDesigner. Then it creates a MenuCommand object using ' one of the commands in the StandardCommands class. Finally, it sets several ' of the properties in the MenuCommand object and adds the MenuCommand object ' to the MenuCommandService object. Public Class CDesigner Inherits System.ComponentModel.Design.ComponentDesigner Public Overrides Sub Initialize(ByVal comp As IComponent) MyBase.Initialize(comp) Dim mcs As IMenuCommandService = CType(comp.Site.GetService(GetType(IMenuCommandService)), IMenuCommandService) Dim mc As New MenuCommand(New EventHandler(AddressOf OnReplace), StandardCommands.Group) mc.Enabled = True mc.Visible = True mc.Supported = True mcs.AddCommand(mc) System.Windows.Forms.MessageBox.Show("Initialize() has been invoked.") End Sub 'Initialize Private Sub OnReplace(ByVal sender As Object, ByVal e As EventArgs) System.Windows.Forms.MessageBox.Show("Replace() has been invoked.") End Sub 'OnReplace End Class 'CDesigner [C#] /* This example illustrates how to add a command of type StandardCommand to a service of type IMenuCommandService. It defines a class that is a designer to a component, called CDesigner. Then it creates a MenuCommand object using one of the commands in the StandardCommands class. Finally, it sets several of the properties in the MenuCommand object and adds the MenuCommand object to the MenuCommandService object. */ public class CDesigner : System.ComponentModel.Design.ComponentDesigner { public override void Initialize(IComponent comp) { base.Initialize(comp); IMenuCommandService mcs = (IMenuCommandService)comp.Site. GetService(typeof(IMenuCommandService)); MenuCommand mc = new MenuCommand(new EventHandler(OnReplace),StandardCommands.Group); mc.Enabled = true; mc.Visible = true; mc.Supported = true; mcs.AddCommand(mc); System.Windows.Forms.MessageBox.Show("Initialize() has been invoked."); } private void OnReplace(object sender, EventArgs e) { System.Windows.Forms.MessageBox.Show("Replace() has been invoked."); } } // End Class Component1 [C++] /* This example illustrates how to add a command of type StandardCommand to a service of type IMenuCommandService. It defines a class that is a designer to a component, called CDesigner. Then it creates a MenuCommand object using one of the commands in the StandardCommands class. Finally, it sets several of the properties in the MenuCommand object and adds the MenuCommand object to the MenuCommandService object. */ public __gc class CDesigner : public ComponentDesigner { public: void Initialize(IComponent* comp) { ComponentDesigner::Initialize(comp); IMenuCommandService* mcs = static_cast<IMenuCommandService*>(comp->Site->GetService(__typeof(IMenuCommandService))); MenuCommand* mc = new MenuCommand(new EventHandler(this, &CDesigner::OnReplace), StandardCommands::Group); mc->Enabled = true; mc->Visible = true; mc->Supported = true; mcs->AddCommand(mc); System::Windows::Forms::MessageBox::Show(S"Initialize() has been invoked."); } private: void OnReplace(Object* /*sender*/, EventArgs* /*e*/) { System::Windows::Forms::MessageBox::Show(S"Replace() has been invoked."); } }; // End Class CDesigner
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.ComponentModel.Design
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
StandardCommands Members | System.ComponentModel.Design Namespace | MenuCommand | CommandID | IMenuCommandService