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()

Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs

Initializes a new instance of the ToolStripDropDownItem class.

C#
protected ToolStripDropDownItem();

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.

C#
// 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 });
}

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ToolStripDropDownItem(String, Image, EventHandler)

Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs

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.

C#
protected ToolStripDropDownItem(string text, System.Drawing.Image image, EventHandler onClick);
C#
protected ToolStripDropDownItem(string? text, System.Drawing.Image? image, EventHandler? onClick);

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ToolStripDropDownItem(String, Image, ToolStripItem[])

Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs

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

C#
protected ToolStripDropDownItem(string text, System.Drawing.Image image, params System.Windows.Forms.ToolStripItem[] dropDownItems);
C#
protected ToolStripDropDownItem(string? text, System.Drawing.Image? image, params System.Windows.Forms.ToolStripItem[]? dropDownItems);

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

ToolStripDropDownItem(String, Image, EventHandler, String)

Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs
Source:
ToolStripDropDownItem.cs

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.

C#
protected ToolStripDropDownItem(string text, System.Drawing.Image image, EventHandler onClick, string name);
C#
protected ToolStripDropDownItem(string? text, System.Drawing.Image? image, EventHandler? onClick, string? name);

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

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10