Information générale
Catégorie:
Gestionnaire d'écran & Écrans
>Oleg,
>
>Your code would surpress the error but would not move focus where you want it to go because after the Valid returns .T. the LostFocus will set focus to the next control in the tab order.
>
>The best solution is to realize that the purpose of the Valid event is to determine whether or not you will allow focus to leave the control and that is it. Deciding where to go only comes into play aftert you have decided to allow the user to leave. The LostFocus is the event that fires when the control will actually lose focus and that is where you should setfocus.
My apologies on that. I remember, that I was able to do setfocus() on the call of modal form from within the valid event ( but cannot reproduce that now).
But, there is still a way to set/control the focus from within the valid event.
You should remember, that the valid event in VFP 5.0 can return not just true or
false, but the integer values also.
Instead of ( in valid)
if
thisform.some_object.setfocus()
else
return .f.
endif
write:
if
return thisform.some_object.tabindex-this.tabindex
else
return 0
endif
This code will set the focus on desirable object and prevent exit, if the condition has not met.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement