DesignerActionHeaderItem 類別

定義

表示智慧標籤面板上的靜態標題項目。 此類別無法獲得繼承。

public ref class DesignerActionHeaderItem sealed : System::ComponentModel::Design::DesignerActionTextItem
public sealed class DesignerActionHeaderItem : System.ComponentModel.Design.DesignerActionTextItem
type DesignerActionHeaderItem = class
    inherit DesignerActionTextItem
Public NotInheritable Class DesignerActionHeaderItem
Inherits DesignerActionTextItem
繼承

範例

下列程式代碼範例示範如何建立 物件的集合 DesignerActionItem

如需實作智慧標記的完整範例,請參閱如何:將智慧標記附加至 Windows Forms元件

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

備註

DesignerActionTextItem如同基類,DesignerActionHeaderItem代表智慧標記面板中的個別靜態文字專案。 不過, DesignerActionHeaderItem 專案會使用粗體文字來顯示。 一般而言,標題專案是用來在面板中建立一組項目的標題。 按兩下標頭專案不會採取任何動作。

個別面板專案會與一起建立面板,方法是呼叫 GetSortedActionItems 類別的 DesignerActionList 方法。

建構函式

DesignerActionHeaderItem(String)

使用提供的名稱字串,初始化 DesignerActionHeaderItem 類別的新執行個體。

DesignerActionHeaderItem(String, String)

使用提供的名稱和分類字串,初始化 DesignerActionHeaderItem 類別的新執行個體。

屬性

AllowAssociate

取得或設定值,指出是否允許這個項目置於具有相同 Category 屬性值的項目群組中。

(繼承來源 DesignerActionItem)
Category

取得項目的群組名稱。

(繼承來源 DesignerActionItem)
Description

取得項目的補充文字。

(繼承來源 DesignerActionItem)
DisplayName

取得這個項目的文字。

(繼承來源 DesignerActionItem)
Properties

取得集合的參考,可用於儲存程式設計人員定義的索引鍵/值組。

(繼承來源 DesignerActionItem)
ShowInSourceView

取得或設定值,這個值表示此項目是否出現在原始程式碼檢視中。

(繼承來源 DesignerActionItem)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱