다음을 통해 공유


DesignerVerb 클래스

정의

디자이너에서 실행할 수 있는 동사를 나타냅니다.

public ref class DesignerVerb : System::ComponentModel::Design::MenuCommand
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
[System.Runtime.InteropServices.ComVisible(true)]
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
type DesignerVerb = class
    inherit MenuCommand
[<System.Runtime.InteropServices.ComVisible(true)>]
type DesignerVerb = class
    inherit MenuCommand
Public Class DesignerVerb
Inherits MenuCommand
상속
DesignerVerb
파생
특성

예제

다음 코드 예제에서는 개체를 만들고 DesignerVerb 구성 요소의 디자인 타임 바로 가기 메뉴에 추가하는 방법을 보여 줍니다.

#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

설명

디자이너 동사는 이벤트 처리기에 연결된 메뉴 명령입니다. 디자이너 동사는 디자인 타임에 구성 요소의 바로 가기 메뉴에 추가됩니다. 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와 연결된 public 속성을 가져옵니다.

(다음에서 상속됨 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)

적용 대상

추가 정보