Form validation problem

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.
 
C

Chris Dunaway

Does your button have it's "CausesValidation" property set to true?
Have you tried calling Form.Validate? Does that help?
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top