DesignerVerb クラス

定義

デザイナーから呼び出すことができる動詞を表します。Represents a verb that can be invoked from a designer.

public ref class DesignerVerb : System::ComponentModel::Design::MenuCommand
[System.Runtime.InteropServices.ComVisible(true)]
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
type DesignerVerb = class
    inherit MenuCommand
Public Class DesignerVerb
Inherits MenuCommand
継承
DesignerVerb
派生
属性

次のコード例は、オブジェクトをDesignerVerb作成し、コンポーネントのデザイン時ショートカットメニューに追加する方法を示しています。The following code example demonstrates how to create DesignerVerb objects and add them to the design-time shortcut menu for a component.

#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::Windows::Forms;

/* 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.
*/
// 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.
private ref class MyDesigner: public ComponentDesigner
{
public:

   property DesignerVerbCollection^ Verbs 
   {
      // DesignerVerbCollection is overridden from ComponentDesigner
      virtual DesignerVerbCollection^ get() override
      {
         if ( m_Verbs == nullptr )
         {
            // Create and initialize the collection of verbs
            m_Verbs = gcnew DesignerVerbCollection;
            m_Verbs->Add( gcnew DesignerVerb( "First Designer Verb",gcnew EventHandler( this, &MyDesigner::OnFirstItemSelected ) ) );
            m_Verbs->Add( gcnew DesignerVerb( "Second Designer Verb",gcnew EventHandler( this, &MyDesigner::OnSecondItemSelected ) ) );
         }

         return m_Verbs;
      }
   }
   MyDesigner(){}

private:
   DesignerVerbCollection^ m_Verbs;
   void OnFirstItemSelected( Object^ /*sender*/, EventArgs^ /*args*/ )
   {
      // Display a message
      MessageBox::Show( "The first designer verb was invoked." );
   }

   void OnSecondItemSelected( Object^ /*sender*/, EventArgs^ /*args*/ )
   {
      // Display a message
      MessageBox::Show( "The second designer verb was invoked." );
   }
};

// Associate MyDesigner with this component type using a DesignerAttribute
[Designer(MyDesigner::typeid)]
public ref class Component1: public System::ComponentModel::Component{};
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.");
        }
    }
}
Imports System.ComponentModel
Imports System.Collections
Imports System.ComponentModel.Design

'  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 VBDesignerVerb
    ' Associate MyDesigner with this component type using a DesignerAttribute
    <Designer(GetType(MyDesigner))> _
    Public Class Component1
        Inherits System.ComponentModel.Component
    End Class 


    '  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.    
    Friend Class MyDesigner
        Inherits ComponentDesigner

        Private m_Verbs As DesignerVerbCollection

        ' DesignerVerbCollection is overridden from ComponentDesigner
        Public Overrides ReadOnly Property Verbs() As DesignerVerbCollection
            Get
                If m_Verbs Is Nothing Then
                    ' Create and initialize the collection of verbs
                    m_Verbs = New DesignerVerbCollection()
                    m_Verbs.Add( New DesignerVerb("First Designer Verb", New EventHandler(AddressOf OnFirstItemSelected)) )
                    m_Verbs.Add( New DesignerVerb("Second Designer Verb", New EventHandler(AddressOf OnSecondItemSelected)) )
                End If
                Return m_Verbs
            End Get
        End Property

        Sub New()
        End Sub 

        Private Sub OnFirstItemSelected(ByVal sender As Object, ByVal args As EventArgs)
            ' Display a message
            System.Windows.Forms.MessageBox.Show("The first designer verb was invoked.")
        End Sub 

        Private Sub OnSecondItemSelected(ByVal sender As Object, ByVal args As EventArgs)
            ' Display a message
            System.Windows.Forms.MessageBox.Show("The second designer verb was invoked.")
        End Sub 
    End Class 
End Namespace

注釈

デザイナー動詞は、イベントハンドラーにリンクされたメニューコマンドです。A designer verb is a menu command linked to an event handler. デザイナー動詞は、デザイン時にコンポーネントのショートカットメニューに追加されます。Designer verbs are added to a component's shortcut menu at design time. Visual Studio では、プロパティウィンドウの [説明] ペインで、 LinkLabelを使用して、各デザイナー動詞も表示されます。In Visual Studio, each designer verb is also listed, using a LinkLabel, in the Description pane of the Properties window.

コンストラクター

DesignerVerb(String, EventHandler)

DesignerVerb クラスの新しいインスタンスを初期化します。Initializes a new instance of the DesignerVerb class.

DesignerVerb(String, EventHandler, CommandID)

DesignerVerb クラスの新しいインスタンスを初期化します。Initializes a new instance of the DesignerVerb class.

プロパティ

Checked

メニュー項目がチェックされているかどうかを示す値を取得または設定します。Gets or sets a value indicating whether this menu item is checked.

(継承元 MenuCommand)
CommandID

メニュー コマンドに関連付けられている CommandID を取得します。Gets the CommandID associated with this menu command.

(継承元 MenuCommand)
Description

動詞に関するメニュー項目の説明を取得または設定します。Gets or sets the description of the menu item for the verb.

Enabled

メニュー項目を使用できるかどうかを示す値を取得します。Gets a value indicating whether this menu item is available.

(継承元 MenuCommand)
OleStatus

メニュー項目の OLE コマンド ステータス コードを取得します。Gets the OLE command status code for this menu item.

(継承元 MenuCommand)
Properties

MenuCommand に関連付けられているパブリック プロパティを取得します。Gets the public properties associated with the MenuCommand.

(継承元 MenuCommand)
Supported

メニュー項目がサポートされているかどうかを示す値を取得または設定します。Gets or sets a value indicating whether this menu item is supported.

(継承元 MenuCommand)
Text

メニュー上の動詞コマンドを説明するテキストを取得します。Gets the text description for the verb command on the menu.

Visible

メニュー項目を表示するかどうかを示す値を取得または設定します。Gets or sets a value indicating whether this menu item is visible.

(継承元 MenuCommand)

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判定します。Determines whether the specified object is equal to the current object.

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(継承元 Object)
Invoke()

コマンドを呼び出します。Invokes the command.

(継承元 MenuCommand)
Invoke(Object)

指定したパラメーターを使用して、コマンドが呼び出されます。Invokes the command with the given parameter.

(継承元 MenuCommand)
MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(継承元 Object)
OnCommandChanged(EventArgs)

CommandChanged イベントを発生させます。Raises the CommandChanged event.

(継承元 MenuCommand)
ToString()

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

イベント

CommandChanged

メニュー コマンドが変更されたときに発生します。Occurs when the menu command changes.

(継承元 MenuCommand)

セキュリティ

NamedPermissionSet
システムリソースにフルアクセスできます。for full access to system resources. 要求の値LinkDemand: InheritanceDemand、。Demand values: LinkDemand, InheritanceDemand. 関連付けられた状態:Associated state:

適用対象

こちらもご覧ください