DesignerActionPropertyItem 类


表示与从 DesignerActionList 派生的类中的属性相关的面板项。Represents a panel item that is associated with a property in a class derived from DesignerActionList. 此类不能被继承。This class cannot be inherited.

public ref class DesignerActionPropertyItem sealed : System::ComponentModel::Design::DesignerActionItem
public sealed class DesignerActionPropertyItem : System.ComponentModel.Design.DesignerActionItem
type DesignerActionPropertyItem = class
    inherit DesignerActionItem
Public NotInheritable Class DesignerActionPropertyItem
Inherits DesignerActionItem


下面的代码示例演示如何创建对象的DesignerActionItem集合。The 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


DesignerActionPropertyItem类表示智能标记面板中的各个项。The DesignerActionPropertyItem class represents individual items in a smart tag panel. 每一项通常与类中的一个属性相关联, 该类派生自DesignerActionList类并由组件作者提供。Each item is typically associated with a property in a class that is derived from the DesignerActionList class and supplied by the component author. 通过属性的名称来维护关联, 如MemberName属性中所示。The association is maintained through the name of the property, as stored in the MemberName property.

通过调用GetSortedActionItems DesignerActionList类的方法, 将各个面板项关联起来以形成面板。Individual panel items are associated together to form a panel by a call to the GetSortedActionItems method of the DesignerActionList class.

若要显示关联属性的值, 该属性必须具有get访问器方法; 若要允许编辑, 该属性必须set具有访问器方法。To display the value of the associated property, that property must have a get accessor method; to allow editing, the property must have a set accessor method. 面板允许用户直接编辑属性项的方式取决于为关联属性的数据类型提供的支持类型信息。The way in which the panel allows direct editing of a property item by the user depends on the supporting type information present for the data type of the associated property. 下表显示了可能的方案。The following table shows the likely scheme.

属性类型信息Property type information 属性项编辑用户界面 (UI)Property item editing user interface (UI)
具有关联的类型编辑器 (UITypeEditor)Has an associated type editor (UITypeEditor) 将显示与基础属性关联的类型编辑器, 用于编辑属性的值。The type editor associated with the underlying property is displayed for editing the property's value.
具有与已知类型 (TypeConverter) 关联的类型转换器Has an associated type converter to a known type (TypeConverter) 将显示已知类型的类型编辑器以编辑属性的值。The type editor for the known type is displayed for editing the property's value. 例如, 要String使用的类型转换器可能会TextBox显示。For example, a type converter to String will likely display a TextBox.
布尔值Boolean value 使用二进制 UI (如复选标记) 显示项。The item is displayed using a binary UI, such as a check mark.
以上都不是。None of the above. 使用数据类型的ToString方法将项显示为不可编辑的文本字符串。The item is displayed as a non-editable text string using the data type's ToString method.

所有基本类型System.Boolean(如) 和常见.NET Framework.NET Framework System.String数据类型 (如) 提供标准类型转换器和编辑器。All fundamental types, such as System.Boolean, and common .NET Framework.NET Framework data types, such as System.String, supply standard type converters and editors. 有关类型转换器的详细信息, 请参阅如何:实现类型转换器通用类型转换For more information about type converters, see How to: Implement a Type Converter or Generalized Type Conversion. 有关类型编辑器的详细信息, 请参阅如何:实现 UI 类型编辑器For more information about type editors, see How to: Implement a UI Type Editor.


DesignerActionPropertyItem(String, String)

用指定的属性和显示名称初始化 DesignerActionPropertyItem 类的新实例。Initializes a new instance of the DesignerActionPropertyItem class, with the specified property and display names.

DesignerActionPropertyItem(String, String, String)

使用指定的属性和类别名称以及显示文本,初始化 DesignerActionPropertyItem 类的新实例。Initializes a new instance of the DesignerActionPropertyItem class, with the specified property and category names, and display text.

DesignerActionPropertyItem(String, String, String, String)

使用指定的属性名称和类别名称以及显示和说明文本,初始化 DesignerActionPropertyItem 类的新实例。Initializes a new instance of the DesignerActionPropertyItem class, with the specified property and category names, and display and description text.



获取或设置一个值,该值表示是否允许将此项放入具有相同 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.

(继承自 DesignerActionItem)

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

(继承自 DesignerActionItem)

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

(继承自 DesignerActionItem)

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

(继承自 DesignerActionItem)

获取与此项关联的属性的名称。Gets the name of the property that this item is associated with.


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

(继承自 DesignerActionItem)

获取或设置将其项供给当前面板的组件。Gets or sets a component that contributes its items to the current panel.


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

(继承自 DesignerActionItem)



确定指定的对象是否等于当前对象。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)

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)