MouseEventArgs.Clicks 속성

정의

마우스 단추를 누르고 놓은 횟수를 가져옵니다.

public:
 property int Clicks { int get(); };
public int Clicks { get; }
member this.Clicks : int
Public ReadOnly Property Clicks As Integer

속성 값

Int32 마우스 단추를 누르고 놓은 횟수를 포함하는 값입니다.

예제

다음 코드 예제에서는이 멤버의 사용을 보여 줍니다. 이 예제에서 이벤트 처리기는 이벤트의 발생을 보고합니다 Control.MouseClick . 이 보고서는 이벤트가 발생하는 시기를 학습하는 데 도움이 되며 디버깅에 도움이 될 수 있습니다. 여러 이벤트 또는 자주 발생하는 이벤트에 대해 보고하려면 메시지를 여러 줄MessageBox.ShowConsole.WriteLine 대체 TextBox 하거나 추가해 보세요.

예제 코드를 실행하려면 예제 코드를 상속 Control하는 형식의 인스턴스(예 Button : a 또는 ComboBox.)가 포함된 프로젝트에 붙여넣습니다. 그런 다음 인스턴스 Control1 이름을 지정하고 이벤트 처리기가 이벤트와 연결되어 있는지 확인합니다 Control.MouseClick .

private void Control1_MouseClick(Object sender, MouseEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Clicks", e.Clicks );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "X", e.X );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Y", e.Y );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Delta", e.Delta );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Location", e.Location );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "MouseClick Event" );
}
Private Sub Control1_MouseClick(sender as Object, e as MouseEventArgs) _ 
     Handles Control1.MouseClick

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Button", e.Button)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Clicks", e.Clicks)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "X", e.X)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Y", e.Y)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Delta", e.Delta)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Location", e.Location)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"MouseClick Event")

End Sub

설명

Windows 인터페이스는 표준 마우스 이벤트를 단일 클릭 또는 두 번 클릭으로 정의하지만 개별 애플리케이션은 더 많은 수의 클릭을 단일 이벤트로 해석할 수 있습니다.

적용 대상

추가 정보