DesignerActionMethodItem 類別

定義

表示智慧標籤面板項目,該項目與衍生自 DesignerActionList 之類別中的方法相關聯。

public ref class DesignerActionMethodItem : System::ComponentModel::Design::DesignerActionItem
public class DesignerActionMethodItem : System.ComponentModel.Design.DesignerActionItem
type DesignerActionMethodItem = class
    inherit DesignerActionItem
Public Class DesignerActionMethodItem
Inherits DesignerActionItem
繼承
DesignerActionMethodItem

範例

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

備註

類別 DesignerActionMethodItem 代表智慧標記面板中的個別專案。 此類型的項目會顯示為作用中的使用者介面專案,例如超連結,它會在衍生自 DesignerActionList的類別中叫用程式設計人員提供的方法。 專案與方法之間的關聯是透過屬性的值 MemberName 來維護。 此專案叫用的方法不得採用參數或傳回值。

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

建構函式

DesignerActionMethodItem(DesignerActionList, String, String)

使用指定的方法和顯示名稱,初始化 DesignerActionMethodItem 類別的新執行個體。

DesignerActionMethodItem(DesignerActionList, String, String, Boolean)

使用指定的方法和顯示名稱,以及旗標 (指出項目是否應出現在其他使用者介面內容中),初始化 DesignerActionMethodItem 類別的新執行個體。

DesignerActionMethodItem(DesignerActionList, String, String, String)

使用指定的方法、顯示和分類名稱,初始化 DesignerActionMethodItem 類別的新執行個體。

DesignerActionMethodItem(DesignerActionList, String, String, String, Boolean)

使用指定的方法、顯示和分類名稱,以及旗標 (指出項目是否應出現在其他使用者介面內容中),初始化 DesignerActionMethodItem 類別的新執行個體。

DesignerActionMethodItem(DesignerActionList, String, String, String, String)

使用指定的方法和分類名稱,以及顯示和說明文字,初始化 DesignerActionMethodItem 類別的新執行個體。

DesignerActionMethodItem(DesignerActionList, String, String, String, String, Boolean)

使用指定的方法和分類名稱、顯示和說明文字,以及旗標 (指出項目是否應出現在其他使用者介面內容中),初始化 DesignerActionMethodItem 類別的新執行個體。

屬性

AllowAssociate

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

(繼承來源 DesignerActionItem)
Category

取得項目的群組名稱。

(繼承來源 DesignerActionItem)
Description

取得項目的補充文字。

(繼承來源 DesignerActionItem)
DisplayName

取得這個項目的文字。

(繼承來源 DesignerActionItem)
IncludeAsDesignerVerb

取得值,指出 DesignerActionMethodItem 應出現在其他使用者介面內容中。

MemberName

取得與這個 DesignerActionMethodItem 相關聯之方法的名稱。

Properties

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

(繼承來源 DesignerActionItem)
RelatedComponent

取得或設定元件,該元件將其 DesignerActionMethodItem 物件提供給目前的面板。

ShowInSourceView

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

(繼承來源 DesignerActionItem)

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
Invoke()

以程式設計的方式執行與 DesignerActionMethodItem 相關聯的方法。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱