DesignerActionItem 類別

定義

為在智慧標籤面板上表示面板項目的型別提供基底類別。

public ref class DesignerActionItem abstract
public abstract class DesignerActionItem
type DesignerActionItem = class
Public MustInherit Class DesignerActionItem
繼承
DesignerActionItem
衍生

範例

下列程式代碼範例示範如何建立 物件的集合 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

備註

類別 DesignerActionItem 可作為類別的抽象基底,這些類別代表智慧標記面板中的個別面板專案,代表類似功能表的使用者介面 (UI) 智慧標記。 .NET Framework 提供衍生類別,這些類別代表智慧標記面板中的不同通用專案,包括純文本、標頭文字、相關聯DesignerActionList類別的屬性和方法,以及設計工具動詞。

一般而言,您的 DesignerAction 功能是在衍生自 DesignerActionList的程式設計人員提供的類別中定義,其中包含一個方法,可將個別面板專案分組在一 GetSortedActionItems 起,以形成智慧標記面板。 DesignerActionPropertyItemDesignerActionMethodItem 型別會與衍生自 DesignerActionList的類別成員相關聯,而且DesignerActionMethodItem當用戶選取其相關聯的面板專案時,就會啟動物件。

注意

Forms和對話框可由衍生自 DesignerActionList的類別成員顯示。 根據預設,這些視窗的父代會是智慧標記面板的容器視窗。 明確將這些子視窗父代為另一個服務或視窗可能會導致專案不正確地顯示。

建構函式

DesignerActionItem(String, String, String)

初始化 DesignerActionItem 類別的新執行個體。

屬性

AllowAssociate

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

Category

取得項目的群組名稱。

Description

取得項目的補充文字。

DisplayName

取得這個項目的文字。

Properties

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

ShowInSourceView

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

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱