DesignerVerb クラス
デザイナから呼び出すことができる動詞を表します。
この型のすべてのメンバの一覧については、DesignerVerb メンバ を参照してください。
System.Object
System.ComponentModel.Design.MenuCommand
System.ComponentModel.Design.DesignerVerb
System.Web.UI.Design.TemplateEditingVerb
<ComVisible(True)>
Public Class DesignerVerb Inherits MenuCommand
[C#]
[ComVisible(true)]
public class DesignerVerb : MenuCommand
[C++]
[ComVisible(true)]
public __gc class DesignerVerb : public MenuCommand
[JScript]
public
ComVisible(true)
class DesignerVerb extends MenuCommand
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
デザイナ動詞とは、イベント ハンドラにリンクされているメニュー コマンドのことです。デザイナ動詞は、実行時にコンポーネントのコンテキスト メニューと [プロパティ] ウィンドウに追加されます。
使用例
[Visual Basic, C#, C++] DesignerVerb オブジェクトを作成し、コンポーネントのデザイン時コンテキスト メニューに追加する方法を次の例に示します。
Imports System
Imports System.ComponentModel
Imports System.Collections
Imports System.ComponentModel.Design
' This sample demonstrates a designer that adds menu commands
' to the design-time context 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 context menu.
Namespace VBDesignerVerb
' Associate MyDesigner with this component type using a DesignerAttribute
<Designer(GetType(MyDesigner))> _
Public Class Component1
Inherits System.ComponentModel.Component
End Class 'Component1
' 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 'New
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 'OnFirstItemSelected
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 'OnSecondItemSelected
End Class 'MyDesigner
End Namespace
[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 context 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 context 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.");
}
}
}
[C++]
#using <mscorlib.dll>
#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 context 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 context menu.
*/
namespace CSDesignerVerb
{
// 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 __gc class MyDesigner : public ComponentDesigner {
public:
// DesignerVerbCollection is overridden from ComponentDesigner
__property DesignerVerbCollection* get_Verbs()
{
if (m_Verbs == 0)
{
// Create and initialize the collection of verbs
m_Verbs = new DesignerVerbCollection();
m_Verbs->Add( new DesignerVerb(S"First Designer Verb",
new EventHandler(this, &MyDesigner::OnFirstItemSelected)) );
m_Verbs->Add( new DesignerVerb(S"Second Designer Verb",
new EventHandler(this, &MyDesigner::OnSecondItemSelected)) );
}
return m_Verbs;
}
MyDesigner()
{
}
private:
DesignerVerbCollection* m_Verbs;
void OnFirstItemSelected(Object* /*sender*/, EventArgs* /*args*/)
{
// Display a message
MessageBox::Show(S"The first designer verb was invoked.");
}
void OnSecondItemSelected(Object* /*sender*/, EventArgs* /*args*/)
{
// Display a message
MessageBox::Show(S"The second designer verb was invoked.");
}
};
// Associate MyDesigner with this component type using a DesignerAttribute
[Designer(__typeof(MyDesigner))]
public __gc class Component1 : public System::ComponentModel::Component
{
};
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.ComponentModel.Design
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)
参照
DesignerVerb メンバ | System.ComponentModel.Design 名前空間 | MenuCommand | IMenuCommandService