MenuCommandとは? わかりやすく解説

MenuCommand イベント


パブリック イベントパブリック イベント

  名前 説明
パブリック イベント CommandChanged メニュー コマンド変更されたときに発生します
参照参照

関連項目

MenuCommand クラス
System.ComponentModel.Design 名前空間
StandardCommands
IMenuCommandService インターフェイス
CommandID クラス

その他の技術情報

Windows フォームデザイナ コマンドと DesignerAction オブジェクト モデル

MenuCommand クラス

Windows メニューまたはツール バーコマンド項目を表します

名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Class MenuCommand
[ComVisibleAttribute(true)] 
public class MenuCommand
[ComVisibleAttribute(true)] 
public ref class MenuCommand
/** @attribute ComVisibleAttribute(true) */ 
public class MenuCommand
ComVisibleAttribute(true) 
public class MenuCommand
解説解説

MenuCommand クラスは、Windowsメニューまたはツール バーコマンドに関する情報表します。IMenuCommandService インターフェイス使用すると、MenuCommand オブジェクトVisual Studio .NETメニュー追加できます

このクラスは、次のメンバ提供します

メモメモ

このクラス適用される HostProtectionAttribute 属性Resources プロパティの値は、SharedState です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的にはアイコンダブルクリックコマンド入力、またはブラウザURL入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラストピックまたは「SQL Server プログラミングホスト保護属性」を参照してください

使用例使用例

MenuCommand オブジェクト作成し、そのプロパティ設定して IMenuCommandService追加するコード例次に示します

Component1 クラスインスタンスフォーム作成しVisual Studio のようなデザイン環境でそのフォーム開きます。F1 キー押して MenuCommand呼び出します。

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design

Namespace VbMenuCommand
    <Designer(GetType(CDesigner))> _
    Public Class Component1
        Inherits System.ComponentModel.Component
        Private components As System.ComponentModel.Container
 = Nothing

        Public Sub New(ByVal
 container As System.ComponentModel.IContainer)
            container.Add(Me)
            InitializeComponent()
        End Sub

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub InitializeComponent()
        End Sub
    End Class

    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
    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 OnF1Help),
 StandardCommands.F1Help)
            mc.Enabled = True
            mc.Visible = True
            mc.Supported = True
            mcs.AddCommand(mc)
            System.Windows.Forms.MessageBox.Show("Initialize()
 has been invoked.")
        End Sub

        Private Sub OnF1Help(ByVal
 sender As Object, ByVal
 e As EventArgs)
            System.Windows.Forms.MessageBox.Show("F1Help has been
 invoked.")
        End Sub
    End Class
End Namespace
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.");
        }
    }
} 
#using <system.dll>
#using <system.design.dll>
#using <system.windows.forms.dll>

using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Security::Permissions;

namespace CppMenuCommand
{
   public ref class CDesigner: public
 ComponentDesigner
   {
   public:
    [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
      virtual void Initialize( IComponent^ comp ) override
      {
         ComponentDesigner::Initialize( comp );
         IMenuCommandService^ mcs = static_cast<IMenuCommandService^>(comp->Site->GetService(
 IMenuCommandService::typeid ));
         MenuCommand^ mc = gcnew MenuCommand( gcnew EventHandler( this,
 &CDesigner::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."
 );
      }
   };
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.ComponentModel.Design.MenuCommand
     System.ComponentModel.Design.DesignerVerb
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuCommand メンバ
System.ComponentModel.Design 名前空間
StandardCommands
IMenuCommandService インターフェイス
CommandID クラス
その他の技術情報
Windows フォームデザイナ コマンドと DesignerAction オブジェクト モデル

MenuCommand コンストラクタ

MenuCommand クラス新しインスタンス初期化します。

名前空間: System.ComponentModel.Design
アセンブリ: System (system.dll 内)
構文構文

使用例使用例

MenuCommand オブジェクト作成し、そのプロパティ設定して IMenuCommandService オブジェクト追加するコード例次に示します

<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand,
 Name:="FullTrust")> _
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 OnF1Help), StandardCommands.F1Help)
        mc.Enabled = True
        mc.Visible = True
        mc.Supported = True
        mcs.AddCommand(mc)
        System.Windows.Forms.MessageBox.Show("Initialize() has
 been invoked.")
    End Sub

    Private Sub OnF1Help(ByVal
 sender As Object, ByVal
 e As EventArgs)
        System.Windows.Forms.MessageBox.Show("F1Help has been
 invoked.")
    End Sub
End Class
[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.");
    }
}
   public ref class CDesigner: public
 ComponentDesigner
   {
   public:
    [PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
      virtual void Initialize( IComponent^ comp ) override
      {
         ComponentDesigner::Initialize( comp );
         IMenuCommandService^ mcs = static_cast<IMenuCommandService^>(comp->Site->GetService(
 IMenuCommandService::typeid ));
         MenuCommand^ mc = gcnew MenuCommand( gcnew EventHandler( this,
 &CDesigner::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."
 );
      }
   };
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuCommand クラス
MenuCommand メンバ
System.ComponentModel.Design 名前空間
IMenuCommandService インターフェイス
CommandID クラス

MenuCommand プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

MenuCommand クラス
System.ComponentModel.Design 名前空間
StandardCommands
IMenuCommandService インターフェイス
CommandID クラス

その他の技術情報

Windows フォームデザイナ コマンドと DesignerAction オブジェクト モデル

MenuCommand メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

MenuCommand クラス
System.ComponentModel.Design 名前空間
StandardCommands
IMenuCommandService インターフェイス
CommandID クラス

その他の技術情報

Windows フォームデザイナ コマンドと DesignerAction オブジェクト モデル

MenuCommand メンバ

Windows メニューまたはツール バーコマンド項目を表します

MenuCommand データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド MenuCommand MenuCommand クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント CommandChanged メニュー コマンド変更されたときに発生します
参照参照

関連項目

MenuCommand クラス
System.ComponentModel.Design 名前空間
StandardCommands
IMenuCommandService インターフェイス
CommandID クラス

その他の技術情報

Windows フォームデザイナ コマンドと DesignerAction オブジェクト モデル


このページでは「.NET Framework クラス ライブラリ リファレンス」からMenuCommandを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMenuCommandを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMenuCommand を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「MenuCommand」の関連用語

MenuCommandのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MenuCommandのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS