Wiki Home

Set Focus


Namespace: Wiki

From VFP help:
Assigns the focus to a control.

You cannot assign the focus to a control if the control's Enabled or Visible property is set to false (.F.), or the control's When event returns false (.F.). .... Once a control has the focus, any user input is directed to that control.

And from the Hackers Guide
Set Focus can't be called from some methods. The ones you're likely to run into are When and Valid. Make your calls from Got Focus and Lost Focus instead.

In VFP 9.0 Set Focus can be called from When and Valid. -- Jörg Karpa
A Set Focus() can make a form prematurely visible. In other words, issuing a Set Focus() in a pre-visibility event can cause the form to become immediately visible. This was in VFP 3 and VFP 5 and I don't know if it is still so in VFP 6. The solution? Delay the Set Focus(). That worked for me.-- Steven Black

It can also trigger the form's Activate() event, as well as the Activate of whatever page it may happen to be placed upon. -- Ed Leafe
Category VFP Methods
( Topic last updated: 2009.03.19 08:52:21 AM )