DesignerVerb Klas

Definitie

Vertegenwoordigt een werkwoord dat kan worden aangeroepen vanuit een ontwerper.

public ref class DesignerVerb : System::ComponentModel::Design::MenuCommand
[System.Runtime.InteropServices.ComVisible(true)]
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
public class DesignerVerb : System.ComponentModel.Design.MenuCommand
[<System.Runtime.InteropServices.ComVisible(true)>]
type DesignerVerb = class
    inherit MenuCommand
type DesignerVerb = class
    inherit MenuCommand
Public Class DesignerVerb
Inherits MenuCommand
Overname
DesignerVerb
Afgeleid
Kenmerken

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u objecten maakt DesignerVerb en toevoegt aan het snelmenu ontwerptijd voor een onderdeel.

#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

Opmerkingen

Een ontwerpwerkwoord is een menuopdracht die is gekoppeld aan een gebeurtenis-handler. Designer-werkwoorden worden toegevoegd aan het snelmenu van een onderdeel tijdens het ontwerp. In Visual Studio wordt elke ontwerpwerkwoord ook weergegeven, met behulp van een LinkLabel, in het deelvenster Description van de venster Eigenschappen.

Constructors

Name Description
DesignerVerb(String, EventHandler, CommandID)

Initialiseert een nieuw exemplaar van de DesignerVerb klasse.

DesignerVerb(String, EventHandler)

Initialiseert een nieuw exemplaar van de DesignerVerb klasse.

Eigenschappen

Name Description
Checked

Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of dit menu-item is ingeschakeld.

(Overgenomen van MenuCommand)
CommandID

Hiermee haalt u de CommandID gekoppelde menuopdracht op.

(Overgenomen van MenuCommand)
Description

Hiermee haalt u de beschrijving van het menu-item voor het werkwoord op of stelt u deze in.

Enabled

Hiermee wordt een waarde opgehaald die aangeeft of dit menu-item beschikbaar is.

(Overgenomen van MenuCommand)
OleStatus

Hiermee haalt u de OLE-opdrachtstatuscode voor dit menu-item op.

(Overgenomen van MenuCommand)
Properties

Hiermee haalt u de openbare eigenschappen op die zijn gekoppeld aan de MenuCommand.

(Overgenomen van MenuCommand)
Supported

Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of dit menu-item wordt ondersteund.

(Overgenomen van MenuCommand)
Text

Hiermee haalt u de tekstbeschrijving op voor de opdracht werkwoord in het menu.

Visible

Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of dit menu-item zichtbaar is.

(Overgenomen van MenuCommand)

Methoden

Name Description
Equals(Object)

Bepaalt of het opgegeven object gelijk is aan het huidige object.

(Overgenomen van Object)
GetHashCode()

Fungeert als de standaardhashfunctie.

(Overgenomen van Object)
GetType()

Hiermee haalt u de Type huidige instantie op.

(Overgenomen van Object)
Invoke()

Roept de opdracht aan.

(Overgenomen van MenuCommand)
Invoke(Object)

Roept de opdracht aan met de opgegeven parameter.

(Overgenomen van MenuCommand)
MemberwiseClone()

Hiermee maakt u een ondiepe kopie van de huidige Object.

(Overgenomen van Object)
OnCommandChanged(EventArgs)

Hiermee wordt de CommandChanged gebeurtenis gegenereerd.

(Overgenomen van MenuCommand)
ToString()

Overschrijft ToString().

gebeurtenis

Name Description
CommandChanged

Treedt op wanneer de menuopdracht wordt gewijzigd.

(Overgenomen van MenuCommand)

Van toepassing op

Zie ook