PRB: SetFocus Doesn't Work When Called in the Valid EventLast reviewed: April 30, 1996Article ID: Q130525 |
The information in this article applies to:
SYMPTOMSThe 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.
CAUSEControl 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.
WORKAROUNDCall 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.
STATUSThis behavior is by design.
MORE INFORMATIONIn FoxPro version 2.x, the _CUROBJ system variable was used to select the object where the cursor was to be moved. This was often placed in the Valid code snippet of an object. The SetFocus method is used in Visual FoxPro to perform the same functionality, but will not work as expected in the Valid event of certain controls.
Steps to Reproduce Behavior
|
Additional reference words: 3.00 VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |