本文整理匯總了C#中System.ComponentModel.Design.MenuCommand類的典型用法代碼示例。如果您正苦於以下問題:C# MenuCommand類的具體用法?C# MenuCommand怎麽用?C# MenuCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MenuCommand類屬於System.ComponentModel.Design命名空間,在下文中一共展示了MenuCommand類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Component1
//引入命名空間
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
namespace CSMenuCommand
{
[Designer(typeof(CDesigner))]
public class Component1 : System.ComponentModel.Component
{
private System.ComponentModel.Container components = null;
public Component1(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Component1()
{
InitializeComponent();
}
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
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(OnF1Help), StandardCommands.F1Help);
mc.Enabled = true;
mc.Visible = true;
mc.Supported = true;
mcs.AddCommand(mc);
System.Windows.Forms.MessageBox.Show("Initialize() has been invoked.");
}
private void OnF1Help(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("F1Help has been invoked.");
}
}
}