Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SetFocus

This method is Visual FoxPro’s answer to _CUROBJ. It allows you to set the focus to any control.

Usage

oObject.SetFocus()

SetFocus works kind of inside out from the way _CUROBJ does its stuff. With _CUROBJ, you assign a value that leads to the object you want. In the new, OOP paradigm, you call the SetFocus method for the object you want to receive focus.

SetFocus can’t be called from some methods. The ones you’re likely to run into are When and Valid. Make your calls from GotFocus and LostFocus instead.

Example

* In a form to edit Employee records,
* the Click method for the "Edit" button might:
ThisForm.First_Name.SetFocus()

See Also

GotFocus, LostFocus, _CurObj