Search

AcceptButton on Windows Form being disabled by Phil Levin

Resolved
as Won't Fix Help for as Won't Fix

1
0
Sign in
to vote
Type: Bug
ID: 776352
Opened: 1/11/2013 10:19:38 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
When a form's AutoValidate property is set to EnablePreventFocusChange the default button is being disabled after you get a validation error. If you fix the validation error and then press ENTER or ALT- for he accelerator key, the button click event does not occur.
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

1. Create a Windows form and add a text box and button to it.
2. Set the form's AutoValidate property to EnablePreventFocusChange.
3. Select the button as the form's AcceptButton.
4. Assign an accelarator key to the button. For example, set the button's text property to "&Save".
5. Set the CausesValidation property for the text box and button to True.
6. Add a Validating event handler for the text box and a Click event handler for the button.
7. In the Validating event handler, if the text box is blank display a message and set e.Cancel to True.
8. Run the program. Leave the text box blank and either tab to the button or click on it. You will get a message.
9. After the message is displayed, type something into the text box then press ENTER
or the accelarator key. You will get a Validating event with no validation error but you will not get a Click event. The accept button no longer works.
10. If you then tab to the button and then put focus back on the text box and press ENTER, the button Click event will return.
11. We need to be able to do implicit validation and validate controls as they lose focus. As a work around, I have set the button's CausesValidation property to False and have added this line of code to the button's Click event handler:
if this.Validate = True
     do whatever processing I need to do
This ensures that the last control that had focus gets validated.

If I do not display an error message in the Validating event but just set e.Cancel to True, the behavior changes. If I leave the text box blank and click on the button, then enter something into the text box, the AcceptButton works. But if I leave the text box blank then tab to the button then enter something into the text box, the AcceptButton does not work.

Product Language

English

Operating System

Windows Server 2008 R2

Operating System Language

English

Actual results

AcceptButton and accelerator key disabled.

Expected results

When using implicit validation which puts focus back on the control that is being validated our users would expect the AcceptButton to work after fixing the error.
File Attachments
File Name Submitted By Submitted On File Size  
AcceptError.zip 1/14/2013 44 KB
AcceptError.zip 1/16/2013 44 KB
Sign in to post a comment.
Posted by Microsoft on 2/11/2013 at 1:53 PM
Hi Phil -

Thank you for reporting this issue. Customer feedback is a critical part of a successful, impactful software product. Unfortunately another part is the reality of schedules and the need to prioritize investments according to the objectives of the product. We have evaluated the issue that you have reported and at this point in the product's lifecycle, it does not meet the criteria to be addressed. This evaluation is carefully done and considers many aspects including the cost of the fix, implications of the change, and the number of reported instances of the issue. Many customers have found it useful to discuss issues like this in the forums (http://www.microsoft.com/communities/forums/default.mspx) where Microsoft and other members of the community can recommend ways of achieving the behavior you are interested in.

Thank you,

The Windows Forms Product Team
Posted by Phil Levin on 1/21/2013 at 11:21 AM
The status was updated to "Won't Fix" but no explanation was provided. Why won't this issue be fixed ?
Posted by Microsoft on 1/18/2013 at 2:54 AM
Hi Phil, thanks for your response. We have received your attachment. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Phil Levin on 1/16/2013 at 7:58 AM
I attached a demo project two days ago but you didn't get it. I have attached it again.
Posted by Microsoft on 1/16/2013 at 12:30 AM
Hi Phil, we want to remind you we need a demo project. Please reply to us as soon as possible. Thanks.
Posted by Microsoft on 1/13/2013 at 11:39 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting a demo project. Please submit this information to us within 4 business days. We look forward to hearing from you with this information.
Posted by Microsoft on 1/11/2013 at 10:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.