Shortcut and CausesValidation

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
 
S

Stoitcho Goutsev \(100\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top