I have written a custom control in C# (inherited from Forms.Control) and it seems to working fine, but if you press the button fast enough a problem occurs: only every other click will call the click event handler. This doesn’t happen if you don’t press it fast (less than once a second). The mouseUp and mouseDown handlers always get called no matter how fast you click the button.
Of course doesn’t happen with the canned winform button.
I cannot use the canned button because I’m writing an application for the .net compact framework, so I need a custom control in order to make the UI more presentable. Also, I tested out my code on the full version of the .net framework, and I still have the same problem.
Any help would be greatly appreciated. Thank you!
If you are clicking rapidly enough, you are getting into
DoubleClickterritory.According to above MSDN Page the order of events are:
The following series of events is raised by the control when such a user action takes place:
If you will notice there is only one
Clickevent perDoubleClickFor a way to disable it try looking at this MSDN Page discussing ControlStyles.
From above link:
So try this in your controls constructor or load event:
Since
SetStyledoes not appear to be in the Compact Framework you could add a DoublClick Event and have it trigger the Click event Programmically like this.