Re: how to determine the next control in validating event

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Bruce Wood (brucewood_at_canada.com)
Date: 01/25/05


Date: 24 Jan 2005 17:01:57 -0800

You want to set CausesValidation on that other, specific control to
false. This will allow that control to gain focus without firing the
Validating event on the text box that the user is leaving. Sort of.

You can read about all the gory details of CausesValidation and
validating in this thread:

http://groups-beta.google.com/group/microsoft.public.dotnet.framework.windowsforms.controls/browse_frm/thread/5ea5d67a73414103/3a87446046433a3b

(watch for line wrap on the URL)

The bottom line is that CausesValidation will (with a few caveats)
solve your problem by preventing your Validating event handler from
being called (sort of... like I said, read the other link), so you
don't have to test for which control has focus in your Validating event
handler.



Relevant Pages

  • Re: Stubborn TextBox validation
    ... CausesValidation does not seem to be documented anywhere that I can ... the Validating event fires when you attempt to ... shift focus away from one control and onto another. ... If your Cancel button is inside a panel on your form ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Form validation problem
    ... CausesValidation is set to true (which basically ensures that the control ... triggers the validating event when it loses focus). ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: immediate data bind transfer
    ... put that code in TextChanged handler. ... > CurrencyManager binds to the Validating event on the Control, ... >> binding capabilities of windows forms controls. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Using Errorprovider with data binding - worth it?
    ... input validation code in the object itself (in the "Set" property method). ... to get the validation code to run I have to set the property value in the ... > converting between control displaying and underlying datasource through ... > the control's Validating event, test if the control's new content is valid, ...
    (microsoft.public.dotnet.framework.windowsforms.databinding)
  • Cancel a validation event based on what comes next
    ... I normally validate the data in a control in that controls validating event. ... I also normally have a Cancel button on each form which does a RejectChanges ...
    (microsoft.public.dotnet.languages.vb)