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

 

Initializes a new instance of the DesignerActionMethodItem class, with the specified method and category names, display and description text, and a flag that indicates whether the item should appear in other user interface contexts.

Namespace:   System.ComponentModel.Design
Assembly:  System.Design (in System.Design.dll)

public DesignerActionMethodItem(
	DesignerActionList actionList,
	string memberName,
	string displayName,
	string category,
	string description,
	bool includeAsDesignerVerb
)

Parameters

actionList
Type: System.ComponentModel.Design.DesignerActionList

The DesignerActionList that contains the method this item is associated with.

memberName
Type: System.String

The case-sensitive name of the method in the class derived from DesignerActionList to invoke through the panel item.

displayName
Type: System.String

The panel text for this item.

category
Type: System.String

The case-sensitive String used to group similar items on the panel.

description
Type: System.String

Supplemental text for this item, used in ToolTips or the status bar.

includeAsDesignerVerb
Type: System.Boolean

A flag that specifies whether to also treat the associated method as a designer verb for the associated component.

If the includeAsDesignerVerb parameter is set to true, then this item is also considered a DesignerVerb; therefore, it will be added to the component's design-time shortcut menu. A list of designer verbs can be accessed through the designer's Verbs collection property.

For more information about how the category parameter is used to group items on a panel, see the GetSortedActionItems method.

The following code example demonstrates how to create a collection of DesignerActionItem objects.

For a full example of implementing smart tags, see How to: Attach Smart Tags to a Windows Forms Component.

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;
}

.NET Framework
Available since 2.0
Return to top
Show: