PRB: SetFocus Doesn't Work When Called in the Valid Event (130525)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
This article was previously published under Q130525 SYMPTOMS
The SetFocus method does not set the focus to the specified control if
placed in the Valid event procedure code of the following controls: list
box, text box, combo box, spinner, and edit box. Instead, the focus is
placed on the next control in the Tab order.
This behavior happens only with list box, edit box, text box, spinner, and
combo box controls. The SetFocus method can be called from the Valid event
of command buttons, option buttons, and check boxes.
CAUSE
Control is passed from the current control to the control whose SetFocus
method is called, then returns to execute the LostFocus event of the
current control. Then the LostFocus by default sets the focus to the next
control in the Tab order.
WORKAROUND
Call the SetFocus method for the desired control in the LostFocus event of
the current control, rather than in the Valid event.
NOTE: The NODEFAULT command can be used to skip the default behavior in any
event or method code, including the LostFocus event. In the case of the
LostFocus event, use of NODEFAULT causes the focus to stay on the current
control rather than moving to the next control in the Tab order.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 8/11/1999 |
---|
Keywords: | KB130525 |
---|
|