Validating Fires When Control Doesn't have focus on form close

  • Thread starter Malachy O'Connor
  • Start date
M

Malachy O'Connor

Hi,

I'm having weird problems with Valadating Events.

I have a number of countrols that handle their own Valadating events
in to perform data validation.
I also have a Custom control that contains Add, Edit, Delete, Save and
Cancel buttons.

The Causes validation property for this control is defaulted to true.
I pickup the mouse enter and leave events on the cancel button in
order to set the custom control CausesValidation property to true or
false depending on whether or not the mouse is over the cancel button.

Works a treat. However
If I press cancel and then close the form the validation method
of the control whoes validation event I had just avoided fires.
Even though the cancel button has focus.

This is the only time that the validation method fires when close
form button is presses (unless the control being validated had
focus).

Any suggestions would be greatly apriciated,

I'm pulling my hair out here.

Cheers,

Malachy
 
M

Markus

Any suggestions would be greatly apriciated,

Is it possible to override the OnClose or OnClosing method of the main
control and set the CausesValidation properties to false? Or is this too
late and the event is fired already before calling OnClosing?

hth
Markus
 
M

Malachy O'Connor

I guess I could do that.
I think i'll play around with it a bit more first though.
I don't think i should have to go to that extreme as (as far as I
know) a control that doesn't have focus should cause validate events
to be raised.
 

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