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

Definizione

Si verifica quando viene fatto clic sull'oggetto 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 

Esempi

Nell'esempio di codice riportato di seguito viene illustrato Textcome Overflowimpostare le TextDirection proprietà, e e come Click gestire l'evento.The following code example demonstrates how to set the Text, Overflow, and TextDirection properties, and handle the Click event. Per eseguire questo esempio, incollare il codice seguente in un form che contiene un ToolStrip oggetto movingToolStrip denominato e InitializeMovingToolStrip una chiamata nel costruttore del form Load o nel gestore eventi.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

Commenti

L' Click evento passa un EventArgs oggetto al relativo gestore eventi, quindi indica solo che si è verificato un clic.The Click event passes an EventArgs to its event handler, so it only indicates that a click has occurred. Se sono necessarie informazioni più specifiche sul mouse (pulsante, numero di clic, rotazione della rotellina o posizione), MouseDown usare MouseUp gli eventi e che MouseEventArgs passano un al gestore dell'evento.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 doppio clic è determinato dalle impostazioni del mouse del sistema operativo dell'utente.A double-click is determined by the mouse settings of the user's operating system. L'utente può impostare un intervallo tra i clic effettuati con un pulsante del mouse in modo che debbano essere considerati come un doppio clic anziché come due clic distinti.The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. L' Click evento viene generato ogni volta che si fa doppio clic su un controllo.The Click event is raised every time a control is double-clicked. Se, ad esempio, si dispone di due gestori eventi per Click gli DoubleClick eventi e di Formun, Click gli DoubleClick eventi e vengono generati quando si fa doppio clic sul form ed entrambi i metodi vengono chiamati.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 si fa doppio clic su un elemento che non supporta l' DoubleClick evento, è possibile che l' Click evento venga generato due volte.If an item is double-clicked that does not support the DoubleClick event, the Click event might be raised twice.

Si applica a