PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Shortcut and CausesValidation

Reply

Shortcut and CausesValidation

 
Thread Tools Rate Thread
Old 09-02-2006, 01:24 PM   #1
=?Utf-8?B?QWxleA==?=
Guest
 
Posts: n/a
Default Shortcut and CausesValidation


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
  Reply With Quote
Old 09-02-2006, 02:46 PM   #2
Stoitcho Goutsev \(100\)
Guest
 
Posts: n/a
Default Re: Shortcut and CausesValidation

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.



--
HTH
Stoitcho Goutsev (100)
"Alex" <Alex@discussions.microsoft.com> wrote in message
news:B558D097-4D15-4013-8D2B-CE7A6653BAA2@microsoft.com...
> 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



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off