ToolStripDropDownButton (Clase) (System.Windows.Forms)

Cambiar vista:
Sin script
Biblioteca de clases de .NET Framework
ToolStripDropDownButton (Clase)

Actualización: noviembre 2007

Representa un control en que al hacer clic muestra un ToolStripDropDown asociado del que el usuario puede seleccionar un elemento único.

Espacio de nombres:  System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)
Sintaxis

Visual Basic (Declaración)
<ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.None Or ToolStripItemDesignerAvailability.ToolStrip Or ToolStripItemDesignerAvailability.StatusStrip)> _
Public Class ToolStripDropDownButton _
	Inherits ToolStripDropDownItem
Visual Basic (Uso)
Dim instance As ToolStripDropDownButton
C#
[ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.None|ToolStripItemDesignerAvailability.ToolStrip|ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripDropDownButton : ToolStripDropDownItem
Visual C++
[ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability::None|ToolStripItemDesignerAvailability::ToolStrip|ToolStripItemDesignerAvailability::StatusStrip)]
public ref class ToolStripDropDownButton : public ToolStripDropDownItem
J#
/** @attribute ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.None|ToolStripItemDesignerAvailability.ToolStrip|ToolStripItemDesignerAvailability.StatusStrip) */
public class ToolStripDropDownButton extends ToolStripDropDownItem
JScript
public class ToolStripDropDownButton extends ToolStripDropDownItem
Comentarios

ToolStripDropDownButton tiene la apariencia de ToolStripButton, pero muestra un área desplegable cuando el usuario hace clic en él. Para ocultar o mostrar la flecha de lista desplegable, establezca la propiedad ShowDropDownArrow. ToolStripDropDownButton aloja un ToolStripOverflowButton que muestra los elementos que desbordan ToolStrip.

Utilice ToolStripDropDownButton para activar controles desplegables familiares como los selectores de color. Establezca la propiedad ShowDropDownArrow en true para indicar más claramente al usuario que hay opciones avanzadas disponibles en la lista desplegable.

Ejemplos

En el ejemplo de código siguiente se muestran tres controles ToolStripButton cuando se hace clic en ToolStripDropDownButton. Los botones cambian el color de primer plano del formulario.

Visual Basic
' 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


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


Jerarquía de herencia

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.ToolStripItem
        System.Windows.Forms.ToolStripDropDownItem
          System.Windows.Forms.ToolStripDropDownButton
            System.Windows.Forms.ToolStripOverflowButton
Seguridad para subprocesos

Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Plataformas

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

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Información de versión

.NET Framework

Compatible con: 3.5, 3.0, 2.0
Vea también

Referencia

Otros recursos