DesignerActionList.GetSortedActionItems メソッド

定義

リストに含まれる DesignerActionItem オブジェクトのコレクションを返します。

public:
 virtual System::ComponentModel::Design::DesignerActionItemCollection ^ GetSortedActionItems();
public virtual System.ComponentModel.Design.DesignerActionItemCollection GetSortedActionItems ();
abstract member GetSortedActionItems : unit -> System.ComponentModel.Design.DesignerActionItemCollection
override this.GetSortedActionItems : unit -> System.ComponentModel.Design.DesignerActionItemCollection
Public Overridable Function GetSortedActionItems () As DesignerActionItemCollection

戻り値

このリスト内の項目を含む DesignerActionItem 配列。

次のコード例では、オブジェクトの 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

注釈

メソッドは virtualGetSortedActionItems 、期待される表示順序で、 クラスから派生したオブジェクトのコレクションを DesignerActionItem 返すように実装されます。 これらの項目には、次の特定の種類を指定できます。

Type 説明
DesignerActionHeaderItem 太字で表示されるグループ ラベル。
DesignerActionTextItem プレーンフォントで表示されるラベル。
DesignerActionPropertyItem プロパティに関連付けられているパネル項目。 基になるプロパティに関連付けられているチェックマークまたはプロパティ エディターを表示することもできます。
DesignerActionMethodItem ハイパーリンクとして表示され、メソッドに関連付けられているパネル項目。

および DesignerActionPropertyItemごとにDesignerActionMethodItem、対応するメソッドまたはプロパティを、 クラスから派生したプログラマ指定のクラスに追加するDesignerActionList必要があります。 各メソッドとプロパティ項目は、アクティブなエントリとして表示されます。ユーザー インターフェイス (UI) を介して操作すると、それぞれ対応するメソッドまたはプロパティが呼び出されます。

プロパティ項目には、対応するプロパティ値の表示と操作を可能にする特別なパネル項目インターフェイスがあります。 詳細については、DesignerActionPropertyItem クラスを参照してください。

返される配列内の項目の順序は、パネルに表示される順序を反映します。 項目は、次の規則を Category 使用して、 プロパティに従ってグループ化されます。

  • 最初に検出された項目のカテゴリは、最初のグループの開始を示します。 後続の各項目が同じカテゴリである限り、そのグループは続行されます。 別の新しいカテゴリの項目が検出されると、新しいグループが作成され、その中に項目が配置されます。

  • アイテムの種類が現在のグループとは異なるが、そのカテゴリが既に使用されている場合、項目は一致する既存のカテゴリに配置されます。

  • 項目にカテゴリがない場合は、パネルの末尾にあるその他のグループに配置されます。 このグループには、 プロパティが AllowAssociatefalse設定されている項目も含まれます。

メソッドは GetSortedActionItems 、パネルが最初に作成されるときに呼び出されます。 パネルに Refresh 表示される項目の一覧を更新するには、 メソッドを呼び出す必要があります。

適用対象

こちらもご覧ください