ToolStripDropDownButton 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示单击时显示关联的 ToolStripDropDown 的控件,用户可从该下拉控件中选择一项。
public ref class ToolStripDropDownButton : System::Windows::Forms::ToolStripDropDownItem
[System.Windows.Forms.Design.ToolStripItemDesignerAvailability(System.Windows.Forms.Design.ToolStripItemDesignerAvailability.StatusStrip | System.Windows.Forms.Design.ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripDropDownButton : System.Windows.Forms.ToolStripDropDownItem
[<System.Windows.Forms.Design.ToolStripItemDesignerAvailability(System.Windows.Forms.Design.ToolStripItemDesignerAvailability.StatusStrip | System.Windows.Forms.Design.ToolStripItemDesignerAvailability.ToolStrip)>]
type ToolStripDropDownButton = class
inherit ToolStripDropDownItem
Public Class ToolStripDropDownButton
Inherits ToolStripDropDownItem
- 继承
- 继承
-
ToolStripDropDownButton
- 派生
- 属性
示例
下面的代码示例在单击 时ToolStripDropDownButton显示三ToolStripButton个控件。 按钮更改窗体的前景色。
// Declare the drop-down button and the items it will contain.
ToolStripDropDownButton^ dropDownButton1;
ToolStripDropDown^ dropDown;
ToolStripButton^ buttonRed;
ToolStripButton^ buttonBlue;
ToolStripButton^ buttonYellow;
void InitializeDropDownButton()
{
dropDownButton1 = gcnew ToolStripDropDownButton;
dropDown = gcnew ToolStripDropDown;
dropDownButton1->Text = "A";
// Set the drop-down on the DropDownButton.
dropDownButton1->DropDown = dropDown;
// Declare three buttons, set their forecolor and text,
// and add the buttons to the drop-down.
buttonRed = gcnew ToolStripButton;
buttonRed->ForeColor = Color::Red;
buttonRed->Text = "A";
buttonBlue = gcnew ToolStripButton;
buttonBlue->ForeColor = Color::Blue;
buttonBlue->Text = "A";
buttonYellow = gcnew ToolStripButton;
buttonYellow->ForeColor = Color::Yellow;
buttonYellow->Text = "A";
buttonBlue->Click += gcnew EventHandler(this,
&Form1::colorButtonsClick);
buttonRed->Click += gcnew EventHandler(this,
&Form1::colorButtonsClick);
buttonYellow->Click += gcnew EventHandler(this,
&Form1::colorButtonsClick);
array<ToolStripItem^>^ ToolStrips =
{buttonRed,buttonBlue,buttonYellow};
dropDown->Items->AddRange(ToolStrips);
toolStrip1->Items->Add(dropDownButton1);
}
// Handle the buttons' click event by setting the forecolor
// of the form to the forecolor of the button that is clicked.
void colorButtonsClick(Object^ sender, EventArgs^ e)
{
ToolStripButton^ senderButton = (ToolStripButton^) sender;
this->ForeColor = senderButton->ForeColor;
}
// internal:
// 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;
}
' Declare the drop-down button and the items it will contain.
Friend WithEvents dropDownButton1 As ToolStripDropDownButton
Friend WithEvents dropDown As ToolStripDropDown
Friend WithEvents buttonRed As ToolStripButton
Friend WithEvents buttonBlue As ToolStripButton
Friend WithEvents buttonYellow As ToolStripButton
Private Sub 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"
dropDown.Items.AddRange(New ToolStripItem() {buttonRed, buttonBlue, buttonYellow})
toolStrip1.Items.Add(dropDownButton1)
End Sub
' Handle the buttons' click event by setting the foreground color of the
' form to the foreground color of the button that is clicked.
Public Sub colorButtonsClick(ByVal sender As [Object], ByVal e As EventArgs) _
Handles buttonRed.Click, buttonBlue.Click, buttonYellow.Click
Dim senderButton As ToolStripButton = CType(sender, ToolStripButton)
Me.ForeColor = senderButton.ForeColor
End Sub
注解
ToolStripDropDownButton 类似于 ToolStripButton,但它在用户单击时会显示下拉区域。 可通过设置 ShowDropDownArrow 属性来隐藏或显示下拉箭头。 ToolStripDropDownButton 承载用于显示溢出 ToolStrip 的项的 ToolStripOverflowButton。
ToolStripDropDownButton使用 激活熟悉的下拉控件,例如颜色选取器。 将 ShowDropDownArrow 属性设置为 true
以更清楚地向用户指示下拉列表中提供了更多选项。
构造函数
ToolStripDropDownButton() |
初始化 ToolStripDropDownButton 类的新实例。 |
ToolStripDropDownButton(Image) |
初始化 ToolStripDropDownButton 类的新实例,使之显示指定的图像。 |
ToolStripDropDownButton(String) |
初始化 ToolStripDropDownButton 类的新实例,使之显示指定的文本。 |
ToolStripDropDownButton(String, Image) |
初始化 ToolStripDropDownButton 类的新实例,使之显示指定的文本和图像。 |
ToolStripDropDownButton(String, Image, EventHandler) |
初始化 ToolStripDropDownButton 类的新实例,使之显示指定的文本和图像并引发 |
ToolStripDropDownButton(String, Image, EventHandler, String) |
初始化 ToolStripDropDownButton 类的新实例,使之具有指定的名称,显示指定的文本和图像,并引发 |
ToolStripDropDownButton(String, Image, ToolStripItem[]) |
初始化 ToolStripDropDownButton 类的新实例。 |
属性
方法
事件
显式接口实现
IDropTarget.OnDragDrop(DragEventArgs) |
引发 DragDrop 事件。 (继承自 ToolStripItem) |
IDropTarget.OnDragEnter(DragEventArgs) |
引发 DragEnter 事件。 (继承自 ToolStripItem) |
IDropTarget.OnDragLeave(EventArgs) |
引发 DragLeave 事件。 (继承自 ToolStripItem) |
IDropTarget.OnDragOver(DragEventArgs) |
引发 |