Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 ClickCount Property
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
MouseButtonEventArgs..::.ClickCount Property

Gets the number of times the button was clicked.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic (Declaration)
Public Property ClickCount As Integer
Visual Basic (Usage)
Dim instance As MouseButtonEventArgs
Dim value As Integer

value = instance.ClickCount

instance.ClickCount = value
C#
public int ClickCount { get; internal set; }
Visual C++
public:
property int ClickCount {
    int get ();
    void set (int value);
}
JScript
public function get ClickCount () : int
public function set ClickCount (value : int)
XAML
Members of this class are either not typically used in XAML, or cannot be used in XAML.

Property Value

Type: System..::.Int32
The number of times the mouse button was clicked.

One use of ClickCount is to determine whether a double mouse click has occurred. Some classes expose events for a double-click, such as the MouseDoubleClick event on the Control class. When a double click event is not exposed on a class, a double click can be detected by using the ClickCount property on the event data.

The following example creates a MouseButtonEventHandler which determines if a single, double, or triple click occurred. ClickCount property is used to determine the number of clicks.

C#
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";
    }
}

Windows Vista

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker