Прочетете на английски Редактиране

Споделяне чрез


ToolStripDropDownButton Constructors

Definition

Initializes a new instance of the ToolStripDropDownButton class.

Overloads

ToolStripDropDownButton()

Initializes a new instance of the ToolStripDropDownButton class.

ToolStripDropDownButton(Image)

Initializes a new instance of the ToolStripDropDownButton class that displays the specified image.

ToolStripDropDownButton(String)

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text.

ToolStripDropDownButton(String, Image)

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text and image.

ToolStripDropDownButton(String, Image, EventHandler)

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text and image and raises the Click event.

ToolStripDropDownButton(String, Image, ToolStripItem[])

Initializes a new instance of the ToolStripDropDownButton class.

ToolStripDropDownButton(String, Image, EventHandler, String)

Initializes a new instance of the ToolStripDropDownButton class that has the specified name, displays the specified text and image, and raises the Click event.

ToolStripDropDownButton()

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class.

public ToolStripDropDownButton ();

Examples

The following code example creates and initializes a ToolStripDropDownButton control.

// Declare the drop-down button and the items it will contain.
internal ToolStripDropDownButton dropDownButton1;
internal ToolStripDropDown dropDown;
internal ToolStripButton buttonRed;
internal ToolStripButton buttonBlue;
internal ToolStripButton buttonYellow;

private void InitializeDropDownButton()
{
    dropDownButton1 = new ToolStripDropDownButton();
    dropDown = new ToolStripDropDown();
    dropDownButton1.Text = "A";

    // Set the drop-down on the ToolStripDropDownButton.
    dropDownButton1.DropDown = dropDown;

    // Set the drop-down direction.
    dropDownButton1.DropDownDirection = ToolStripDropDownDirection.Left;

    // Do not show a drop-down arrow.
    dropDownButton1.ShowDropDownArrow = false;

    // Declare three buttons, set their foreground color and text, 
    // and add the buttons to the drop-down.
    buttonRed = new ToolStripButton();
    buttonRed.ForeColor = Color.Red;
    buttonRed.Text = "A";

    buttonBlue = new ToolStripButton();
    buttonBlue.ForeColor = Color.Blue;
    buttonBlue.Text = "A";

    buttonYellow = new ToolStripButton();
    buttonYellow.ForeColor = Color.Yellow;
    buttonYellow.Text = "A";
    
    buttonBlue.Click += new EventHandler(colorButtonsClick);
    buttonRed.Click += new EventHandler(colorButtonsClick);
    buttonYellow.Click += new EventHandler(colorButtonsClick);

    dropDown.Items.AddRange(new ToolStripItem[] 
        { buttonRed, buttonBlue, buttonYellow });
    toolStrip1.Items.Add(dropDownButton1);
}

// Handle the buttons' click event by setting the foreground color of the
// form to the foreground color of the button that is clicked.
private void colorButtonsClick(object sender, EventArgs e)
{
    ToolStripButton senderButton = (ToolStripButton)sender;
    this.ForeColor = senderButton.ForeColor;
}

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(Image)

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class that displays the specified image.

public ToolStripDropDownButton (System.Drawing.Image image);
public ToolStripDropDownButton (System.Drawing.Image? image);

Parameters

image
Image

An Image to be displayed on the ToolStripDropDownButton.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(String)

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text.

public ToolStripDropDownButton (string text);
public ToolStripDropDownButton (string? text);

Parameters

text
String

The text to be displayed on the ToolStripDropDownButton.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(String, Image)

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text and image.

public ToolStripDropDownButton (string text, System.Drawing.Image image);
public ToolStripDropDownButton (string? text, System.Drawing.Image? image);

Parameters

text
String

The text to be displayed on the ToolStripDropDownButton.

image
Image

An Image to be displayed on the ToolStripDropDownButton.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(String, Image, EventHandler)

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class that displays the specified text and image and raises the Click event.

public ToolStripDropDownButton (string text, System.Drawing.Image image, EventHandler onClick);
public ToolStripDropDownButton (string? text, System.Drawing.Image? image, EventHandler? onClick);

Parameters

text
String

The text to be displayed on the ToolStripDropDownButton.

image
Image

An Image to be displayed on the ToolStripDropDownButton.

onClick
EventHandler

The event handler for the Click event.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(String, Image, ToolStripItem[])

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class.

public ToolStripDropDownButton (string text, System.Drawing.Image image, params System.Windows.Forms.ToolStripItem[] dropDownItems);
public ToolStripDropDownButton (string? text, System.Drawing.Image? image, params System.Windows.Forms.ToolStripItem[]? dropDownItems);

Parameters

text
String

The text to be displayed on the ToolStripDropDownButton.

image
Image

An Image to be displayed on the ToolStripDropDownButton.

dropDownItems
ToolStripItem[]

An array of type ToolStripItem containing the items of the ToolStripDropDownButton.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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

ToolStripDropDownButton(String, Image, EventHandler, String)

Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs
Source:
ToolStripDropDownButton.cs

Initializes a new instance of the ToolStripDropDownButton class that has the specified name, displays the specified text and image, and raises the Click event.

public ToolStripDropDownButton (string text, System.Drawing.Image image, EventHandler onClick, string name);
public ToolStripDropDownButton (string? text, System.Drawing.Image? image, EventHandler? onClick, string? name);

Parameters

text
String

The text to be displayed on the ToolStripDropDownButton.

image
Image

An Image to be displayed on the ToolStripDropDownButton.

onClick
EventHandler

The event handler for the Click event.

name
String

The name of the ToolStripDropDownButton.

Applies to

.NET Framework 4.8.1 и други версии
Продукт Версии
.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