Vb net validating close

Darin *** Sent via Developersdex Yes, closing the form causes 'validating' to take place. I have come to the belief that the problem we are seeing with the escape key is a bug.

One, remove the "control Box" from the form, so the user cant close it that way. in the btn Cancel_Click event: Removehandeler Text Box1.validating, Addressof Text Box1_Validating -- Terry "Darin" wrote: I know that, but the problem is when the user clicks EXIT, the textbox.validating event is called BEFORE the cancel.click is done, so the textbox is being validated. According to the documentation: "The cancel button for a form is the button control that is clicked whenever the user presses the ESC key." Which says to me the behavior s/b the same! To Short Date String Else Msg Box("Please enter a valid date.") e.

Doing so can cause your application or the operating system to stop responding.

For more information, see the WM_KILLFOCUS topic in the "Keyboard Input Reference" section, and the "Message Deadlocks" section of the "About Messages and Message Queues" topic in the MSDN library at

This was fixed by the following in the cancel button click event: Setting Causes Validation to false is the key, however this alone is not enough.

I have a Windows Form with an edit box and a Cancel button. The code is executed every time the edit box loses focus.

Then in the btn Cancel_click event, either set a module level variable like m Canceling to True and then in the validating event ... It doesn't need to be validated because the user is exiting. Length Yes, closing the form causes 'validating' to take place. Close() End Sub Private Sub Text Box1_Validating(By Val sender As Object, By Val e As System. I am going to start a new thread - calling it a bug and see what happens. Down (Down Arrow) and some how (and I never figured this one out) the next control in the tab order, regardless of the Tab Stop property, got focus. Cancel = True End If End If End Sub Hi Al, Nearly 40 years for me since my first college FORTRAN IV class! Well, one of the keys you would not see in either the keypress or keydown events is the tab key, which of course will move the focus.

Darin *** Sent via Developersdex Yes, closing the form causes 'validating' to take place. One, remove the "control Box" from the form, so the user cant close it that way. in the btn Cancel_Click event: Removehandeler Text Box1.validating, Addressof Text Box1_Validating -- Terry That doesn't work either, at least not for VB2005. -- Al Reid (who didn't mean to hijack the thread) "Terry" Well it works for me - but one thing I left out - you need to set the cancel buttons 'causes validation' to false. I reprogrammed the device to only send the CR and now the problem is solved. Validating If Not mbln Cancel Then Dim dte Date As Date Time If Date Time. Why it would stop on a textbox with tabstop property set to False - I have no idea, unless it is a behavior of the container its in. Maybe you should be using the Key Down event instead of the Key Press event. here is a line copied from the documentation: "The Key Press event is not raised by noncharacter keys; however, the noncharacter keys do raise the Key Down and Key Up events." My guess is that the gun is sending some noncharacter data to you.

I am experiencing an issue using the 'x' button to close my form if invalid or no data is present in the textbox with focus when I click the 'x' button. You can change the data to something valid and close fine but this is aggrevating.

I changed the forms causevalidation attribute to false and created a sub to handle formclosing. Form Closing 'Disable validating when form is closed without exit button.

Leave a Reply