Shortcut and CausesValidation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a button with a shortcut (&Cancel) and property CausesValidation =
false.
When I click on the button the validating event is not fired but when I use
the shorcut it's fired.
Is there any solution to have the same behaviour with click and shorcut
(event not fired) ?

Thanks

Alex
 
Alex,

This is very strange behavior I must admit. It is even more that it works in
the same way in .NET 2.0.

The problem is that when the menonic key is pressed ProcessMnemonic calls
PerformClick that kicks in the validation without checking the
CausesValidation flag.

I don't see other solution than to create your own button class and to
override PerformMnemonic viartual method. Form inside the override don't
call the base class, but rather fire the click event either calling directly
OnClick method or calling InvokeOnClick (which will do basically the same.
 
Back
Top