Link to home
Start Free TrialLog in
Avatar of FrancineTaylor
FrancineTaylor

asked on

How do I trigger all Validating/Validated events on all controls on a form?


I am using my Validated events to move data from my form to the class object containing my data.  When the "Save" button is clicked, I want to make certain that all the Validated events have been triggered.  There are some test fields that just have data put into them as a result of choices being made on other controls.

So I'd like to build a method that just triggers the Validating event for all the controls, and if the control validates, trigger the Validated event.

The method would look something like this:

static public void TriggerValidations(Control.ControlCollection pcb)
{
      foreach (Control ctl in pcb)
      {
                // trigger Validating event
                // if control Validated without error
                {
                         //trigger Validated event
                 }
         }
}

Is this possible?
ASKER CERTIFIED SOLUTION
Avatar of e1v
e1v

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial