Editar

Compartilhar via


ToolStripDropDownItem Constructors

Definition

Initializes a new instance of the ToolStripDropDownItem class.

Overloads

ToolStripDropDownItem()

Initializes a new instance of the ToolStripDropDownItem class.

ToolStripDropDownItem(String, Image, EventHandler)

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, and action to take when the drop-down control is clicked.

ToolStripDropDownItem(String, Image, ToolStripItem[])

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, and ToolStripItem collection that the drop-down control contains.

ToolStripDropDownItem(String, Image, EventHandler, String)

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, action to take when the drop-down control is clicked, and control name.

Remarks

You must derive a drop-down control from the ToolStripDropDownItem class in order to have any drop-down functionality for a ToolStripDropDownButton, ToolStripMenuItem, or ToolStripSplitButton control.

ToolStripDropDownItem()

Initializes a new instance of the ToolStripDropDownItem class.

protected:
 ToolStripDropDownItem();
protected ToolStripDropDownItem ();
Protected Sub New ()

Examples

The following code example demonstrates how to create and initialize ToolStripDropDownItem controls. This code example is part of a larger example provided for the ToolStripDropDownItem class.

// This utility method creates and initializes three 
// ToolStripDropDownItem controls and adds them 
// to the form's ToolStrip control.
private void InitializeToolStripDropDownItems()
{
    ToolStripDropDownButton b = new ToolStripDropDownButton("DropDownButton");
    b.DropDown = this.contextMenuStrip1;
    b.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    b.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    b.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    ToolStripMenuItem m = new ToolStripMenuItem("MenuItem");
    m.DropDown = this.contextMenuStrip1;
    m.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    m.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    m.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    ToolStripSplitButton sb = new ToolStripSplitButton("SplitButton");
    sb.DropDown = this.contextMenuStrip1;
    sb.DropDownClosed += new EventHandler(toolStripDropDownItem_DropDownClosed);
    sb.DropDownItemClicked += new ToolStripItemClickedEventHandler(toolStripDropDownItem_DropDownItemClicked);
    sb.DropDownOpened += new EventHandler(toolStripDropDownItem_DropDownOpened);

    this.toolStrip1.Items.AddRange(new ToolStripItem[] { b, m, sb });
}
' This utility method creates and initializes three 
' ToolStripDropDownItem controls and adds them 
' to the form's ToolStrip control.
Private Sub InitializeToolStripDropDownItems()
   Dim b As New ToolStripDropDownButton("DropDownButton")
   b.DropDown = Me.contextMenuStrip1
   AddHandler b.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler b.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler b.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Dim m As New ToolStripMenuItem("MenuItem")
   m.DropDown = Me.contextMenuStrip1
   AddHandler m.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler m.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler m.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Dim sb As New ToolStripSplitButton("SplitButton")
   sb.DropDown = Me.contextMenuStrip1
   AddHandler sb.DropDownClosed, AddressOf toolStripDropDownItem_DropDownClosed
   AddHandler sb.DropDownItemClicked, AddressOf toolStripDropDownItem_DropDownItemClicked
   AddHandler sb.DropDownOpened, AddressOf toolStripDropDownItem_DropDownOpened
   
   Me.toolStrip1.Items.AddRange(New ToolStripItem() {b, m, sb})
End Sub

Remarks

You must derive a drop-down control from the ToolStripDropDownItem class in order to have any drop-down functionality for a ToolStripDropDownButton, ToolStripMenuItem, or ToolStripSplitButton control.

Applies to

ToolStripDropDownItem(String, Image, EventHandler)

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, and action to take when the drop-down control is clicked.

protected:
 ToolStripDropDownItem(System::String ^ text, System::Drawing::Image ^ image, EventHandler ^ onClick);
protected ToolStripDropDownItem (string text, System.Drawing.Image image, EventHandler onClick);
protected ToolStripDropDownItem (string? text, System.Drawing.Image? image, EventHandler? onClick);
new System.Windows.Forms.ToolStripDropDownItem : string * System.Drawing.Image * EventHandler -> System.Windows.Forms.ToolStripDropDownItem
Protected Sub New (text As String, image As Image, onClick As EventHandler)

Parameters

text
String

The display text of the drop-down control.

image
Image

The Image to be displayed on the control.

onClick
EventHandler

The action to take when the drop-down control is clicked.

Remarks

You must derive a drop-down control from the ToolStripDropDownItem class in order to have any drop-down functionality for a ToolStripDropDownButton, ToolStripMenuItem, or ToolStripSplitButton control.

Applies to

ToolStripDropDownItem(String, Image, ToolStripItem[])

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, and ToolStripItem collection that the drop-down control contains.

protected:
 ToolStripDropDownItem(System::String ^ text, System::Drawing::Image ^ image, ... cli::array <System::Windows::Forms::ToolStripItem ^> ^ dropDownItems);
protected ToolStripDropDownItem (string text, System.Drawing.Image image, params System.Windows.Forms.ToolStripItem[] dropDownItems);
protected ToolStripDropDownItem (string? text, System.Drawing.Image? image, params System.Windows.Forms.ToolStripItem[]? dropDownItems);
new System.Windows.Forms.ToolStripDropDownItem : string * System.Drawing.Image * System.Windows.Forms.ToolStripItem[] -> System.Windows.Forms.ToolStripDropDownItem
Protected Sub New (text As String, image As Image, ParamArray dropDownItems As ToolStripItem())

Parameters

text
String

The display text of the drop-down control.

image
Image

The Image to be displayed on the control.

dropDownItems
ToolStripItem[]

A ToolStripItem collection that the drop-down control contains.

Remarks

You must derive a drop-down control from the ToolStripDropDownItem class in order to have any drop-down functionality for a ToolStripDropDownButton, ToolStripMenuItem, or ToolStripSplitButton control.

Applies to

ToolStripDropDownItem(String, Image, EventHandler, String)

Initializes a new instance of the ToolStripDropDownItem class with the specified display text, image, action to take when the drop-down control is clicked, and control name.

protected:
 ToolStripDropDownItem(System::String ^ text, System::Drawing::Image ^ image, EventHandler ^ onClick, System::String ^ name);
protected ToolStripDropDownItem (string text, System.Drawing.Image image, EventHandler onClick, string name);
protected ToolStripDropDownItem (string? text, System.Drawing.Image? image, EventHandler? onClick, string? name);
new System.Windows.Forms.ToolStripDropDownItem : string * System.Drawing.Image * EventHandler * string -> System.Windows.Forms.ToolStripDropDownItem
Protected Sub New (text As String, image As Image, onClick As EventHandler, name As String)

Parameters

text
String

The display text of the drop-down control.

image
Image

The Image to be displayed on the control.

onClick
EventHandler

The action to take when the drop-down control is clicked.

name
String

The name of the control.

Applies to