RE: Bug or Feature? CancelButton vs Escape Key
- From: jetan@xxxxxxxxxxxxxxxxxxxx ("Jeffrey Tan[MSFT]")
- Date: Tue, 18 Jul 2006 12:36:04 GMT
Hi Terry,
Sorry for let you wait.
Yes, after performing some research, I found that some customers had
reported the similar issue as a bug. The problem lies in that the ESC key
causes the validating from Button.PerformClick method, while clicking
button will trigger the validating through Control.WmSetFocus internal
method. So it seems that Button.PerformClick method does not check
Button.CauseValidation correctly internally.
Please refer to the bug link below for more information:
"CausesValidation has no effect on Button when PerformClick is called. "
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedbac
kID=116242
To workaround this problem, you may intercept the ESC key explicitly and
set AutoValidate property to AutoValidate.Disable to disable the
validating, sample code snippet is listed below:
Protected Overrides Function ProcessDialogKey(ByVal keyData As
System.Windows.Forms.Keys) As Boolean
Dim cancel As Button = CType(Me.CancelButton, Button)
If keyData = Keys.Escape Then
Me.AutoValidate = Windows.Forms.AutoValidate.Disable
cancel.PerformClick()
Me.AutoValidate = Windows.Forms.AutoValidate.Inherit
Return True
End If
Return MyBase.ProcessDialogKey(keyData)
End Function
Thank you for reporting this bug and sorry for introducing any
inconvinience to you.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- RE: Bug or Feature? CancelButton vs Escape Key
- From: Terry
- RE: Bug or Feature? CancelButton vs Escape Key
- Prev by Date: Re: Access files from .NET Windows Service
- Next by Date: Re: help regarding creation of mailing labels.
- Previous by thread: RE: Bug or Feature? CancelButton vs Escape Key
- Next by thread: RE: Bug or Feature? CancelButton vs Escape Key
- Index(es):