P
Patrick De Ridder
How do I connect to an event being thrown when a field has
lost focus? Could you please give a code example?
lost focus? Could you please give a code example?
100 said:Hi Patric,
A bunch of events are fired when the control loses the focus.
The right order is:
Leave
Validating
Validated
LostFocus
According to the event order above. You will receive LostFocus only if the
focus is actually lost and Leave as a inforamtion when request for changing
the focus has arrived. Validating event handler can cancel the request and
it is posible to receive Leave, but not to receive LostFocus.
Anyway there is a bug in the framework and this order is valid only when the
focus has been chaged using the TAB key to circle among the controls. If you
use the mouse for changing the focus (which is most often used I think) the
event order is:
LostFocus
Leave
Validating
Validated
You can see that you will receive LostFocus first and then the others
events. Validating event handler can cancel the operation and the focus
won't be changed even though you have received LostFocus.
So, the LostFocus is not reliable.
I haven't seen good workaround for this bug. Some people suggest catching
Windows messages, other using some special flags inside the form class. But
I think there is no universal cure for this. Until MS don't fix this the
best workaround depends on the application logic.
This is the right way to do it. I just warned you about a well known bug inI have applied what mk advised me to do,
and that works fine.So I am very pleased.
Sorry prig = prog(gram)I will read up on validation, since that appears to be your main concern,
and I will have been warned by you not to combine it with the focus stuff.
Actually I do quite a bit of data validation (my code) in the prig, alerting
the user in the case of incorrect prig use with message boxes. Should I
understand from you that there are better alternatives to this approach?