0
votes

My form contains a UserControl, and for now on this I have a MouseDown event handler, which works with a MouseEventArgs. However, I'd like to get an event handler with a MouseButtonEventArgs, so that I can access ClicksCount property to distinguish between simple and double clicking. For now I've some code found on StackOverflow that ways for double click time to be elapsed to know how many times were clicked but this causes redraw being delayed, so it's not user-friendly. Redraw is speedy in itself.

The UserControl displays a background image and small images drawn onto, from user clicks.

So how can I bind an event to an event handler that accepts a MouseButtonEventArgs event? MouseDown, both on UserControl or parent Form, only likes a MouseEventArgs.

I use pure Winforms, not WPF for this project.

Thank you for helping me finding.

1

1 Answers

0
votes

So how can I bind an event to an event handler that accepts a MouseButtonEventArgs event? MouseDown, both on UserControl or parent Form, only likes a MouseEventArgs.

You cannot. MouseButtonEventArgs is for WPF. WinForms uses MouseEventArgs.

If you want to catch double clicks, you should handle the DoubleClick event.

For now I've some code found on StackOverflow that ways for double click time to be elapsed to know how many times were clicked but this causes redraw being delayed

This is the only way to know that a click event was a double-click. The only way to tell the difference is to wait the system-specified double-click interval. If a second click happens within that time, it should be interpreted as a double-click. If there is no second click, or it happened outside of that time span, the original click should be interpreted as a single click.

If you don't want the operation to be delayed, you need to react to a single click.