MouseButtonEventArgs.ClickCount 属性

定义

获取单击此按钮的次数。

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

属性值

单击此鼠标按钮的次数。

示例

以下示例创建一个 , MouseButtonEventHandler 它确定是发生单次、双击还是三次单击。 ClickCount 属性用于确定单击次数。

private void OnMouseDownClickCount(object sender, MouseButtonEventArgs e)
{
    // Checks the number of clicks.
    if (e.ClickCount == 1)
    {
        // Single Click occurred.
        lblClickCount.Content = "Single Click";
    }
    if (e.ClickCount == 2)
    {
        // Double Click occurred.
        lblClickCount.Content = "Double Click";
    }
    if (e.ClickCount >= 3)
    {
        // Triple Click occurred.
        lblClickCount.Content = "Triple Click";
    }
}
Private Sub OnMouseDownClickCount(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
    ' Checks the number of clicks.
    If e.ClickCount = 1 Then
        ' Single Click occurred.
        lblClickCount.Content = "Single Click"
    End If
    If e.ClickCount = 2 Then
        ' Double Click occurred.
        lblClickCount.Content = "Double Click"
    End If
    If e.ClickCount >= 3 Then
        ' Triple Click occurred.
        lblClickCount.Content = "Triple Click"
    End If
End Sub

注解

ClickCount 一个用途是确定是否发生了双击鼠标。 某些类公开双击的事件,例如 MouseDoubleClick 类上的 Control 事件。 当类上未公开双击事件时,可以通过对事件数据使用 ClickCount 属性来检测双击。

适用于

另请参阅