Form validation problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, i'm trying to force validation of each control in a form by setting focus
explicitly on each control prior to calling this.Validate(). The idea is to
ensure that the data is validated when the user presses the ok button on the
form. The problem is that setting focus on some controls alters the state of
the control. For example, setting focus on radiobuttons sets the checked
state to true. Is there anyway to force control validation without altering
the state of the control? I saw one eample using reflection, forcing the
control's validation event to occur, but i dont want to reflect into the
private methods of the .net framework for future compability.
 
Does your button have it's "CausesValidation" property set to true?
Have you tried calling Form.Validate? Does that help?
 
CausesValidation is set to true (which basically ensures that the control
triggers the validating event when it loses focus). Form.Validate triggers
validation on the control which currently has focus (stupid but true), which
is why i traverse all controls in the form, setting focus and calling
form.Validate.
 
Back
Top