1

I would like to use the built-in Validation framework in my VB.NET Windows Forms application.

In a form I need to validate a specific control in the form. This I can easily obtain by manually calling ValidateChildren() when needed. However I also need to do a form wide validation not specific to any control.

I tried to do this by calling Me.Validate() (for the form) and handle the Me.Validating event. However when calling Me.Validate() the event is not fired for some reason.

I have CauseValidation = True set for the form and all controls.

How can I obtain what I want using the built-in validation framework?

Marcus Mangelsdorf
  • 2,852
  • 1
  • 30
  • 40
SuppaiKamo
  • 285
  • 2
  • 5
  • 16
  • is this what you try to achieve? - http://stackoverflow.com/questions/558621/why-is-my-validating-event-not-firing-in-c – Rex Aug 02 '13 at 09:35
  • 1
    No, I know how to validate the children, but I need to fire some custom not control related code when i call the form.validate procedure (which should fire the form.validating event). – SuppaiKamo Aug 02 '13 at 11:13
  • I just experienced exactly the same behavior and would also be very interested in an answer :) – Marcus Mangelsdorf May 10 '16 at 08:29

1 Answers1

1

I just discovered that the behavior described in the question is by design.

From MSDN (highlights by me):

ContainerControl.Validate Method ()

(..)

Remarks

The Validate method validates the last child control that is not validated and its ancestors up through, but not including, the current container control.

Marcus Mangelsdorf
  • 2,852
  • 1
  • 30
  • 40