Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações. |
Tradução
Original
|
Classe ToolStripDropDownButton
Representa um Controle que, quando clicado, exibe um ToolStripDropDown associado, onde o usuário pode selecionar um item único.
Assembly: System.Windows.Forms (em System.Windows.Forms.dll)
O ToolStripDropDownButton parece com o ToolStripButton, mas mostra um menu drop-down quando o usuário clica nele. Oculta ou mostra a seta do drop-down definindo a propriedade ShowDropDownArrow. O ToolStripDropDownButton hospeda um ToolStripOverflowButton que exibe itens que ultrapassam a área do ToolStrip.
Use o ToolStripDropDownButton para ativar controles drop-down familiares, como telas de seleção de cores. Defina a propriedade ShowDropDownArrow como true para indicar mais claramente ao usuário que opções adicionais estão disponíveis na lista drop-down.
O exemplo de código a seguir exibe três ToolStripButton Controla quando o ToolStripDropDownButton é clicado. Os botões alteram a cor da letra do formulário.
// 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; privatevoid 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.privatevoid colorButtonsClick(object sender, EventArgs e) { ToolStripButton senderButton = (ToolStripButton)sender; this.ForeColor = senderButton.ForeColor; }
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.ToolStripItem
System.Windows.Forms.ToolStripDropDownItem
System.Windows.Forms.ToolStripDropDownButton
System.Windows.Forms.ToolStripOverflowButton
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
o.NET Framework e.NET Compact Framework não oferecem suporte a todas as versões de cada plataforma. Para obter uma lista de versões suportadas, consulte Requisitos de sistema do .NET framework.