英語で読む

次の方法で共有


DesignerVerb クラス

定義

デザイナーから呼び出すことができる動詞を表します。

C#
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
C#
[System.Runtime.InteropServices.ComVisible(true)]
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
継承
DesignerVerb
派生
属性

次のコード例では、オブジェクトを作成 DesignerVerb し、コンポーネントのデザイン時ショートカット メニューに追加する方法を示します。

C#
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;

/* This sample demonstrates a designer that adds menu commands
    to the design-time shortcut menu for a component.

    To test this sample, build the code for the component as a class library, 
    add the resulting component to the toolbox, open a form in design mode, 
    and drag the component from the toolbox onto the form. 

    The component should appear in the component tray beneath the form. 
    Right-click the component.  The verbs should appear in the shortcut menu.
*/

namespace CSDesignerVerb
{
    // Associate MyDesigner with this component type using a DesignerAttribute
    [Designer(typeof(MyDesigner))]
    public class Component1 : System.ComponentModel.Component
    {
    }

    // This is a designer class which provides designer verb menu commands for 
    // the associated component. This code is called by the design environment at design-time.
    internal class MyDesigner : ComponentDesigner
    {
        DesignerVerbCollection m_Verbs;

        // DesignerVerbCollection is overridden from ComponentDesigner
        public override DesignerVerbCollection Verbs
        {
            get 
            {
                if (m_Verbs == null) 
                {
                    // Create and initialize the collection of verbs
                    m_Verbs = new DesignerVerbCollection();
            
                    m_Verbs.Add( new DesignerVerb("First Designer Verb", new EventHandler(OnFirstItemSelected)) );
                    m_Verbs.Add( new DesignerVerb("Second Designer Verb", new EventHandler(OnSecondItemSelected)) );
                }
                return m_Verbs;
            }
        }

        MyDesigner() 
        {
        }

        private void OnFirstItemSelected(object sender, EventArgs args) 
        {
            // Display a message
            System.Windows.Forms.MessageBox.Show("The first designer verb was invoked.");
        }

        private void OnSecondItemSelected(object sender, EventArgs args) 
        {
            // Display a message
            System.Windows.Forms.MessageBox.Show("The second designer verb was invoked.");
        }
    }
}

注釈

デザイナー動詞は、イベント ハンドラーにリンクされたメニュー コマンドです。 デザイナー動詞は、デザイン時にコンポーネントのショートカット メニューに追加されます。 Visual Studio では、各デザイナー動詞も、プロパティ ウィンドウの [説明] ウィンドウに を使用してLinkLabel一覧表示されます。

コンストラクター

DesignerVerb(String, EventHandler)

DesignerVerb クラスの新しいインスタンスを初期化します。

DesignerVerb(String, EventHandler, CommandID)

DesignerVerb クラスの新しいインスタンスを初期化します。

プロパティ

Checked

メニュー項目がチェックされているかどうかを示す値を取得または設定します。

(継承元 MenuCommand)
CommandID

メニュー コマンドに関連付けられている CommandID を取得します。

(継承元 MenuCommand)
Description

動詞に関するメニュー項目の説明を取得または設定します。

Enabled

メニュー項目を使用できるかどうかを示す値を取得します。

(継承元 MenuCommand)
OleStatus

メニュー項目の OLE コマンド ステータス コードを取得します。

(継承元 MenuCommand)
Properties

MenuCommand に関連付けられているパブリック プロパティを取得します。

(継承元 MenuCommand)
Supported

メニュー項目がサポートされているかどうかを示す値を取得または設定します。

(継承元 MenuCommand)
Text

メニュー上の動詞コマンドを説明するテキストを取得します。

Visible

メニュー項目を表示するかどうかを示す値を取得または設定します。

(継承元 MenuCommand)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
Invoke()

コマンドを呼び出します。

(継承元 MenuCommand)
Invoke(Object)

指定したパラメーターを使用して、コマンドが呼び出されます。

(継承元 MenuCommand)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnCommandChanged(EventArgs)

CommandChanged イベントを発生させます。

(継承元 MenuCommand)
ToString()

ToString() をオーバーライドします。

イベント

CommandChanged

メニュー コマンドが変更されたときに発生します。

(継承元 MenuCommand)

適用対象

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

こちらもご覧ください