DesignerActionItem 类


为表示智能标记面板上的面板项的类型提供基类。Provides the base class for types that represent a panel item on a smart tag panel.

public ref class DesignerActionItem abstract
public abstract class DesignerActionItem
type DesignerActionItem = class
Public MustInherit Class DesignerActionItem


下面的代码示例演示如何创建对象的集合 DesignerActionItemThe following code example demonstrates how to create a collection of DesignerActionItem objects.

有关实现智能标记的完整示例,请参阅 如何:将智能标记附加到 Windows 窗体组件For a full example of implementing smart tags, see How to: Attach Smart Tags to a Windows Forms Component.

public override DesignerActionItemCollection GetSortedActionItems()
    DesignerActionItemCollection items = new DesignerActionItemCollection();

    //Define static section header entries.
    items.Add(new DesignerActionHeaderItem("Appearance"));
    items.Add(new DesignerActionHeaderItem("Information"));

    //Boolean property for locking color selections.
    items.Add(new DesignerActionPropertyItem("LockColors",
                     "Lock Colors", "Appearance",
                     "Locks the color properties."));
    if (!LockColors)
        items.Add(new DesignerActionPropertyItem("BackColor",
                         "Back Color", "Appearance",
                         "Selects the background color."));
        items.Add(new DesignerActionPropertyItem("ForeColor",
                         "Fore Color", "Appearance",
                         "Selects the foreground color."));

        //This next method item is also added to the context menu 
        // (as a designer verb).
        items.Add(new DesignerActionMethodItem(this,
                         "InvertColors", "Invert Colors",
                         "Inverts the fore and background colors.",
    items.Add(new DesignerActionPropertyItem("Text",
                     "Text String", "Appearance",
                     "Sets the display text."));

    //Create entries for static Information section.
    StringBuilder location = new StringBuilder("Location: ");
    StringBuilder size = new StringBuilder("Size: ");
    items.Add(new DesignerActionTextItem(location.ToString(),
    items.Add(new DesignerActionTextItem(size.ToString(),

    return items;
Public Overrides Function GetSortedActionItems() _
As DesignerActionItemCollection
    Dim items As New DesignerActionItemCollection()

    'Define static section header entries.
    items.Add(New DesignerActionHeaderItem("Appearance"))
    items.Add(New DesignerActionHeaderItem("Information"))

    'Boolean property for locking color selections.
    items.Add(New DesignerActionPropertyItem( _
    "LockColors", _
    "Lock Colors", _
    "Appearance", _
    "Locks the color properties."))

    If Not LockColors Then
        items.Add( _
        New DesignerActionPropertyItem( _
        "BackColor", _
        "Back Color", _
        "Appearance", _
        "Selects the background color."))

        items.Add( _
        New DesignerActionPropertyItem( _
        "ForeColor", _
        "Fore Color", _
        "Appearance", _
        "Selects the foreground color."))

        'This next method item is also added to the context menu 
        ' (as a designer verb).
        items.Add( _
        New DesignerActionMethodItem( _
        Me, _
        "InvertColors", _
        "Invert Colors", _
        "Appearance", _
        "Inverts the fore and background colors.", _
    End If
    items.Add( _
    New DesignerActionPropertyItem( _
    "Text", _
    "Text String", _
    "Appearance", _
    "Sets the display text."))

    'Create entries for static Information section.
    Dim location As New StringBuilder("Location: ")
    Dim size As New StringBuilder("Size: ")

    items.Add( _
    New DesignerActionTextItem( _
    location.ToString(), _

    items.Add( _
    New DesignerActionTextItem( _
    size.ToString(), _

    Return items
End Function


DesignerActionItem类用作表示智能标记面板中各个面板项的类的抽象基类,智能标记面板中表示类似菜单的用户界面 (UI) 用于智能标记。The DesignerActionItem class serves as an abstract base for classes that represent individual panel items in a smart tag panel, which represents a menu-like user interface (UI) for smart tags. .NET Framework.NET Framework提供派生类,这些类表示智能标记面板中的不同常见项,包括纯文本、标题文本、关联类的属性和方法以及 DesignerActionList 设计器谓词。The .NET Framework.NET Framework supplies derived classes that represent the different common entries in a smart tag panel, including plain text, header text, properties and methods of the associated DesignerActionList class, and designer verbs.

通常,你的 DesignerAction 功能在从派生的程序员提供的类中定义 DesignerActionList ,后者包含一 GetSortedActionItems 种方法,该方法将各个面板项组合在一起以形成智能标记面板。Typically, your DesignerAction feature is defined in a programmer-supplied class derived from DesignerActionList, which contains a GetSortedActionItems method that groups individual panel items together to form the smart tag panel. DesignerActionPropertyItemDesignerActionMethodItem 类型与派生自的类的成员相关联 DesignerActionListDesignerActionMethodItem 当用户选择其关联的面板条目时,将激活对象。The DesignerActionPropertyItem and DesignerActionMethodItem types are associated with members of the class derived from DesignerActionList, and DesignerActionMethodItem objects are activated when their associated panel entry is selected by the user.


窗体和对话框可由派生自的类的成员显示 DesignerActionListForms and dialog boxes can be displayed by members of the class derived from DesignerActionList. 默认情况下,这些窗口的父级将是智能标记面板的 "容器" 窗口。By default, the parent of these windows will be the container window for the smart tag panel. 将这些子窗口显式地父子到其他服务或窗口可能导致项显示不正确。Explicitly parenting these child windows to another service or window may cause items to display improperly.


DesignerActionItem(String, String, String)

初始化 DesignerActionItem 类的新实例。Initializes a new instance of the DesignerActionItem class.



获取或设置一个值,该值表示是否允许将此项放入具有相同 Category 属性值的一组项中。Gets or sets a value indicating whether to allow this item to be placed into a group of items that have the same Category property value.


获取某个项的组名。Gets the group name for an item.


获取项的补充文本。Gets the supplemental text for the item.


获取此项的文本。Gets the text for this item.


获取对一个集合的引用,该集合可用于存储程序员定义的键/值对。Gets a reference to a collection that can be used to store programmer-defined key/value pairs.


获取或设置指示此项目是否在源代码视图中显示的值。Gets or sets a value that indicates whether this item appears in source code view.



确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)