DesignerActionPropertyItem 构造函数

定义

初始化 DesignerActionPropertyItem 类的新实例。

重载

DesignerActionPropertyItem(String, String)

用指定的属性和显示名称初始化 DesignerActionPropertyItem 类的新实例。

DesignerActionPropertyItem(String, String, String)

使用指定的属性和类别名称以及显示文本,初始化 DesignerActionPropertyItem 类的新实例。

DesignerActionPropertyItem(String, String, String, String)

使用指定的属性名称和类别名称以及显示和说明文本,初始化 DesignerActionPropertyItem 类的新实例。

DesignerActionPropertyItem(String, String)

用指定的属性和显示名称初始化 DesignerActionPropertyItem 类的新实例。

public:
 DesignerActionPropertyItem(System::String ^ memberName, System::String ^ displayName);
public DesignerActionPropertyItem (string memberName, string displayName);
public DesignerActionPropertyItem (string memberName, string? displayName);
new System.ComponentModel.Design.DesignerActionPropertyItem : string * string -> System.ComponentModel.Design.DesignerActionPropertyItem
Public Sub New (memberName As String, displayName As String)

参数

memberName
String

与此面板项关联的属性的名称(区分大小写)。

displayName
String

此项的面板文本。

注解

构造 DesignerActionPropertyItem(String, String) 函数将 CategoryDescription 属性设置为 null

参数 memberName 引用关联属性的名称,该属性是从 类派生的程序员提供的类的成员 DesignerActionList

另请参阅

适用于

DesignerActionPropertyItem(String, String, String)

使用指定的属性和类别名称以及显示文本,初始化 DesignerActionPropertyItem 类的新实例。

public:
 DesignerActionPropertyItem(System::String ^ memberName, System::String ^ displayName, System::String ^ category);
public DesignerActionPropertyItem (string memberName, string displayName, string category);
public DesignerActionPropertyItem (string memberName, string? displayName, string? category);
new System.ComponentModel.Design.DesignerActionPropertyItem : string * string * string -> System.ComponentModel.Design.DesignerActionPropertyItem
Public Sub New (memberName As String, displayName As String, category As String)

参数

memberName
String

与此面板项关联的属性的名称(区分大小写)。

displayName
String

此项的面板文本。

category
String

用于对面板上的相似项进行分组的、区分大小写的 String

注解

构造 DesignerActionPropertyItem(String, String, String) 函数将 Description 属性设置为 null

有关如何 category 使用 参数对面板上的项进行分组的详细信息,请参阅 GetSortedActionItems 方法。

参数 memberName 引用关联属性的名称,该属性是从 派生 DesignerActionList的程序员提供的类的成员。

另请参阅

适用于

DesignerActionPropertyItem(String, String, String, String)

使用指定的属性名称和类别名称以及显示和说明文本,初始化 DesignerActionPropertyItem 类的新实例。

public:
 DesignerActionPropertyItem(System::String ^ memberName, System::String ^ displayName, System::String ^ category, System::String ^ description);
public DesignerActionPropertyItem (string memberName, string displayName, string category, string description);
public DesignerActionPropertyItem (string memberName, string? displayName, string? category, string? description);
new System.ComponentModel.Design.DesignerActionPropertyItem : string * string * string * string -> System.ComponentModel.Design.DesignerActionPropertyItem
Public Sub New (memberName As String, displayName As String, category As String, description As String)

参数

memberName
String

与此面板项关联的属性的名称(区分大小写)。

displayName
String

此项的面板文本。

category
String

用于对面板上的相似项进行分组的、区分大小写的 String

description
String

此项的补充文本,用在工具提示或状态栏中。

示例

下面的代码示例演示如何创建 对象的集合 DesignerActionItem 。 有关实现智能标记的完整示例,请参阅如何:将智能标记附加到Windows 窗体组件

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",
                         "Appearance",
                         "Inverts the fore and background colors.",
                          true));
    }
    items.Add(new DesignerActionPropertyItem("Text",
                     "Text String", "Appearance",
                     "Sets the display text."));

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

    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.", _
        True))
    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: ")
    location.Append(colLabel.Location)
    Dim size As New StringBuilder("Size: ")
    size.Append(colLabel.Size)

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

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

    Return items
End Function

注解

有关如何 category 使用 参数对面板上的项进行分组的详细信息,请参阅 GetSortedActionItems 方法。

参数 memberName 引用关联属性的名称,该属性是从 类派生的程序员提供的类的成员 DesignerActionList

另请参阅

适用于