You should take a look at the sequence of events. In a textbox it goes
like this:
when-gotfocus-keypress-valid-lostfocus.
I have a little form that shows you in what order events fire, which I
can send to you if you want.
You should program your validation code in the textboxes of the columns.
When you move away from the current row, the valid event of the textbox
fires and if it succeds, control goes to the lostfocus event
In order to control what to do when there is success or failure, you
should return 1 (to jump to the next control, passing first through the
lostfocus method) or 0 if you want the user to stay on the textbox.
example
textbox init
this.addproperty('lValid',.t.)
textbox valid
** this code lets you close the form or avoid validation if you click on
the x at the right hand corner of the form
** works in conjunction with the keypress event
if lastkey() = 27 or empty(this.value) escape key or mouse click pressed
this.lValid = .f.
endif
if lValid
if this.value = your control code if successful
return 1 go directly to the lostfocus event and run the
code there
else
pop an error message
return 0 user will only leave this control if valid code is
introduced or escape key is pressed
endif
endif
keypress event
LPARAMETERS nKeyCode, nShiftAltCtrl
if nKeyCode = 27
release thisform
endif
lostfocus event
if this lValid
run whatever code if validation succeds
else
this.lValid = .t. && reset this property's value
endif
The above is the basic, but you can complicate it a little bit more, by
adding:
textbox valid
if lastkey() = 27 or empty(this.value) or lastkey() = 28 escape key
or mouse click or F10 pressed
this.lValid = .f.
endif
keypress event
LPARAMETERS nKeyCode, nShiftAltCtrl
if nKeyCode = 27
release thisform
endif
if nKeyCode = 28
call a lookup form to consult a price list for instance
endif
Rafael Copquin
El 29/10/2013 14:50, Gene Wirchenko escribió:
Dear Vixens and Reynards:
What is the best way to define a fixed reference to a column?
When the operator tries to move away from the current row, I want
the current control's validation to be done, and if that succeeds,
then the row-level validation to be done. If the row-level validation
fails, I want to set the focus on the first (measuring from the left)
applicable control.
The issue: Gird's .ActiveColumn is according to the physical
order which may have changed from the start because columns can be put
in a different order.
An example from my app is the following validation rule:
basicchg+ovrhdfee=dsbamt+xsvamt
If the columns were still in that order, the row-level validation
failing, the focus should go to the basicchg control. If the order
were changed to, say,
dsbamt xsvamt basicchg ovrhdfee
then the focus should go to the dsbamt control. How do I find out
which control is the leftmost?
Suppose I just want the basicchg control to get the focus. How do
I figure out its .ActiveColumn (or do an equivalent thing) so that I
can .setFocus() appropriately.
Sincerely,
Gene Wirchenko
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.