ToolStripItem.Click Evento

Definição

Ocorre quando o ToolStripItem é clicado.Occurs when the ToolStripItem is clicked.

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

Exemplos

O exemplo de código a seguir demonstra como definir Textas OverflowPropriedades, TextDirection , e, e manipular Click o evento.The following code example demonstrates how to set the Text, Overflow, and TextDirection properties, and handle the Click event. Para executar este exemplo, Cole o código a seguir em um formulário que contenha movingToolStrip um nome InitializeMovingToolStrip e uma ToolStrip chamada no construtor do Load formulário ou no manipulador 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

Comentários

O Click evento passa um EventArgs para seu manipulador de eventos, portanto, ele indica apenas que um clique ocorreu.The Click event passes an EventArgs to its event handler, so it only indicates that a click has occurred. Se você precisar de informações mais específicas sobre o mouse (botão, número de cliques, rotação de roda ou local) MouseDown , MouseUp use os eventos e MouseEventArgs que passam um para o manipulador 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.

O clique duplo é determinado pelas configurações do mouse do sistema operacional do usuário.A double-click is determined by the mouse settings of the user's operating system. O usuário pode definir o tempo entre cliques de um botão do mouse que deve ser considerado um clique duplo em vez de dois cliques.The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. O Click evento é gerado toda vez que um controle é clicado duas vezes.The Click event is raised every time a control is double-clicked. Por exemplo, se você tiver dois manipuladores de eventos para Click os DoubleClick eventos e de Forma, Click os DoubleClick eventos e serão gerados quando o formulário for clicado duas vezes e ambos os métodos forem chamados.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. Se um item for clicado duas vezes que não oferece suporte DoubleClick ao evento, Click o evento poderá ser gerado duas vezes.If an item is double-clicked that does not support the DoubleClick event, the Click event might be raised twice.

Aplica-se a