That works just fine, but when the user press ALT F4, or presses the X in the upper right corner of the window it still goes through the event. When we were using VB6 the same code was in the lost focus, and when the user pressed ALT F4, and the X the Lost Focus event did not fire, or acted like it did not fire.We have also tried moving the code to the Validating event, but it behaives similar to the Leave event?When I run our sample in VS 2005 and press Cancel, it is doing the validation and blocking the close. The only things we do validation-related are these: 1) Give you access to the Causes Validation properties of each of the buttons.By default we set the Cancel button's Causes Validation to false. By default Back, Cancel, and Help have Causes Validation set to false, while Next and Finish have it set to true.Pressing the Cancel button bypasses Validating, which is perfect. Add(panel); In this simplified example the textbox will not let you proceed if there are 3 characters input.
I am using VB 2005 and the latest version of the wizard control When I run our sample in VS 2002 and press Cancel, it closes the Form fine. Could you add the Form Closing or a similar event so that fires before validation fires?
Is there any way of making the Escape key perform as intended, i.e. I just saw this problem as I was hunting a solution for the same and the override of Processdialog Key is the MS-approved solution until they fix the bug (Escape should do the same as clicking Cancel).
not raise the Validating event, just as if the Cancel button had been pressed? A discussion of this bug is also found here (just working with Visual Basic instead of C#.
If a form have value in certain text box (say Text Box1), Then I want to validate that the save button is clicked before closing the form (whether close button or the 'X' button at top is pressed).
But if there is no value in that text box or the form is just initialized and user just want to close the form, it simply closes the form. Are you familiar with creating property's or create a boolean so that if the savebutton is clicked you store the value and upon close check that value first.true the allow the form to close else alert the user to click the save button and I believe that should be checked in the formclosing eventprivate bool _has Changes; private void text Box1_Text Changed(object sender, Event Args e) private void form_Form Closing(object sender, Form Closing Event Args e) private void Save() private void button Save_Click(object sender, Event Args e) private void button Ok_Click(object sender, Event Args e) private void button Cancel_Click(object sender, Event Args e) Tie into the Closing Event and use your Event Handler to validate that textbox.