ToolStripItem.Click 이벤트

정의

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 

예제

다음 코드 예제에서는 설정 하는 방법에 설명 합니다 Text, Overflow, 및 TextDirection 속성 및 처리를 Click 이벤트.The following code example demonstrates how to set the Text, Overflow, and TextDirection properties, and handle the Click event. 이 예제를 실행 하려면 다음 코드를 포함 하는 형식으로 붙여넣습니다를 ToolStrip 라는 movingToolStrip 호출 InitializeMovingToolStrip 폼의 생성자에서 또는 Load 이벤트 처리기입니다.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

설명

합니다 Click 이벤트를 전달는 EventArgs 해당 이벤트 처리기에 따라서 것만 클릭 되었음을 나타냅니다.The Click event passes an EventArgs to its event handler, so it only indicates that a click has occurred. 보다 구체적인 마우스 정보 (단추 클릭 횟수, 휠이 회전 또는 위치)에 필요한 경우 사용 합니다 MouseDownMouseUp 전달 하는 이벤트를 MouseEventArgs 이벤트 처리기에 합니다.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.

두 번 클릭은 운영 체제의 마우스 설정에 따라 결정 됩니다.A double-click is determined by the mouse settings of the user's operating system. 천천히 두 번 클릭하는 것이 아닌 두 번 클릭(double-click)으로 간주될 수 있도록 마우스 단추 클릭 간격을 설정할 수 있습니다.The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. Click 컨트롤을 두 번 클릭할 때마다 이벤트가 발생 합니다.The Click event is raised every time a control is double-clicked. 예를 들어, 두 명의 이벤트 처리기에 대 한 경우는 ClickDoubleClick 이벤트를 FormClickDoubleClick 이벤트가 폼을 두 번 클릭 하 고 두 메서드 모두 호출 됩니다.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. 항목을 두 번 클릭 하는 경우를 지원 하지 않는 합니다 DoubleClick 이벤트는 Click 이벤트가 두 번 발생할 수 있습니다.If an item is double-clicked that does not support the DoubleClick event, the Click event might be raised twice.

적용 대상