ToolStripItem.Click ToolStripItem.Click ToolStripItem.Click ToolStripItem.Click Event

Definición

Se produce cuando se hace clic en ToolStripItem.Occurs when the ToolStripItem is clicked.

public:
 event EventHandler ^ Click;
public event EventHandler Click;
member this.Click : EventHandler 
Public Custom Event Click As EventHandler 

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer el Text, Overflow, y TextDirection propiedades y controle el Click eventos.The following code example demonstrates how to set the Text, Overflow, and TextDirection properties, and handle the Click event. Para ejecutar este ejemplo, pegue el código siguiente en un formulario que contenga un ToolStrip denominado movingToolStrip y llamar a InitializeMovingToolStrip en el constructor del formulario o Load controlador de eventos.To run this example, paste the following code into a form that contains a ToolStrip named movingToolStrip and call InitializeMovingToolStrip in the form's constructor or Load event handler.

ToolStripButton^ changeDirectionButton;

void InitializeMovingToolStrip()
{
    changeDirectionButton = gcnew ToolStripButton;
    movingToolStrip->AutoSize = true;
    movingToolStrip->RenderMode = ToolStripRenderMode::System;
    changeDirectionButton->TextDirection = 
        ToolStripTextDirection::Vertical270;
    changeDirectionButton->Overflow = 
        ToolStripItemOverflow::Never;
    changeDirectionButton->Text = "Change Alignment";
    movingToolStrip->Items->Add(changeDirectionButton);
    changeDirectionButton->Click += gcnew EventHandler(this, 
        &Form1::changeDirectionButtonClick);
}

void changeDirectionButtonClick(Object^ sender, EventArgs^ e)
{
    ToolStripItem^ item = (ToolStripItem^) sender;
    if ((item->TextDirection == ToolStripTextDirection::Vertical270) 
        || (item->TextDirection == ToolStripTextDirection::Vertical90))
    {
        item->TextDirection = ToolStripTextDirection::Horizontal;
        movingToolStrip->Raft = RaftingSides::Top;
    }
    else
    {
        item->TextDirection = 
            ToolStripTextDirection::Vertical270;
        movingToolStrip->Raft = RaftingSides::Left;
    }
}


internal ToolStripButton changeDirectionButton;

private void InitializeMovingToolStrip()
{
          movingToolStrip = new ToolStrip();

	changeDirectionButton = new ToolStripButton();

	movingToolStrip.AutoSize = true;
	movingToolStrip.RenderMode = ToolStripRenderMode.System;

	changeDirectionButton.TextDirection = ToolStripTextDirection.Vertical270;
	changeDirectionButton.Overflow = ToolStripItemOverflow.Never;
	changeDirectionButton.Text = "Change Alignment";
		movingToolStrip.Items.Add(changeDirectionButton);
}


private void changeDirectionButton_Click(object sender, EventArgs e)
{

	ToolStripItem item = (ToolStripItem)sender;

	if (item.TextDirection == ToolStripTextDirection.Vertical270 || item.TextDirection == ToolStripTextDirection.Vertical90)
	{
		item.TextDirection = ToolStripTextDirection.Horizontal;
		movingToolStrip.Dock = System.Windows.Forms.DockStyle.Top;
	}
	else
	{
		item.TextDirection = ToolStripTextDirection.Vertical270;
		movingToolStrip.Dock = System.Windows.Forms.DockStyle.Left;
	}

}
Friend WithEvents changeDirectionButton As ToolStripButton

Private Sub InitializeMovingToolStrip()
    changeDirectionButton = New ToolStripButton()

    movingToolStrip.AutoSize = True
    movingToolStrip.RenderMode = ToolStripRenderMode.System

    changeDirectionButton.TextDirection = ToolStripTextDirection.Vertical270
    changeDirectionButton.Overflow = ToolStripItemOverflow.Never
    changeDirectionButton.Text = "Change Alignment"
    movingToolStrip.Items.Add(changeDirectionButton)
End Sub


Public Sub changeDirectionButton_Click(ByVal sender As Object, _
    ByVal e As EventArgs) Handles changeDirectionButton.Click

    Dim item As ToolStripItem = CType(sender, ToolStripItem)

    If item.TextDirection = ToolStripTextDirection.Vertical270 _
        OrElse item.TextDirection = ToolStripTextDirection.Vertical90 Then

        item.TextDirection = ToolStripTextDirection.Horizontal
        movingToolStrip.Dock = System.Windows.Forms.DockStyle.Top
    Else
        item.TextDirection = ToolStripTextDirection.Vertical270
        movingToolStrip.Dock = System.Windows.Forms.DockStyle.Left
    End If

End Sub

Comentarios

El Click evento pasa una EventArgs a su controlador de eventos, por lo tanto, sólo indica que se ha producido un clic.The Click event passes an EventArgs to its event handler, so it only indicates that a click has occurred. Si necesita información más específica de mouse (botón, número de clics, rotación de la rueda o ubicación), use el MouseDown y MouseUp eventos que pasan un MouseEventArgs al controlador de eventos.If you need more specific mouse information (button, number of clicks, wheel rotation, or location), use the MouseDown and MouseUp events which pass a MouseEventArgs to the event handler.

Un doble clic viene determinada por la configuración del mouse del sistema operativo del usuario.A double-click is determined by the mouse settings of the user's operating system. El usuario puede establecer el tiempo entre los clics de un botón del mouse que debe considerarse como un doble clic y no como dos clics.The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. El Click evento se desencadena cada vez que se hace doble clic en un control.The Click event is raised every time a control is double-clicked. Por ejemplo, si tiene dos controladores de eventos para el Click y DoubleClick eventos de un Form, Click y DoubleClick se generan eventos cuando se hace doble clic en el formulario y se llama a ambos métodos.For example, if you have two event handlers for the Click and DoubleClick events of a Form, the Click and DoubleClick events are raised when the form is double-clicked and both methods are called. Si se hace doble clic en un elemento que no admite la DoubleClick eventos, el Click evento podría generarse dos veces.If an item is double-clicked that does not support the DoubleClick event, the Click event might be raised twice.

Se aplica a