DesignerActionTextItem 類別

定義

表示智慧標籤面板上的靜態文字項目。

public ref class DesignerActionTextItem : System::ComponentModel::Design::DesignerActionItem
public class DesignerActionTextItem : System.ComponentModel.Design.DesignerActionItem
type DesignerActionTextItem = class
    inherit DesignerActionItem
Public Class DesignerActionTextItem
Inherits DesignerActionItem
繼承
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 代表智慧標記面板中的個別靜態文字專案。 個別專案會透過從呼叫 GetSortedActionItems 方法傳回群組,以形成面板。

最常見的是,靜態文字專案是用來在面板中建立資訊標籤。 按兩下靜態文字專案不會造成任何動作。 衍生類型 DesignerActionHeaderItem 通常用來建立標籤來分隔類別。

建構函式

DesignerActionTextItem(String, String)

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

屬性

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)

適用於

另請參閱