本文整理匯總了C#中System.ComponentModel.Design.DesignerVerb類的典型用法代碼示例。如果您正苦於以下問題:C# DesignerVerb類的具體用法?C# DesignerVerb怎麽用?C# DesignerVerb使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DesignerVerb類屬於System.ComponentModel.Design命名空間,在下文中一共展示了DesignerVerb類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: if
//引入命名空間
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.");
}
}
}