Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
This.setfocus not setting focus
Message
De
19/01/2000 09:02:19
 
 
À
19/01/2000 08:49:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00319809
Message ID:
00319819
Vues:
17
>Hello there,
>I have a listbox on my form, and when the user types something, and presses return, I want that value to be entered into a listbox, and then keep the focus on the textbox to potentially enter more data. Here is my code from the textbox's keypress event.
>
>LPARAMETERS nKeyCode, nShiftAltCtrl
>if nKeyCode = 13
> this.parent.command1.click()
> this.setfocus
>endif
>
>The line this.parent.command1.click() properly fires that buttons click event which is what enters the textbox's value into the listbox. However, this.setfocus doesn't return the focus back to the textbox (remember, this code is from my textbox.keypress event). The focus, instead, remains on the command1, whose click event is fired by this code. Any idea of why it performs this way, and how I can get the focus where I want it?

Howabout this code in the valid of the textbox instead:

IF LASTKEY() = 13
THIS.Parent.Command1.Click()
RETURN .F.
ENDIF


Unsolicited advice:
It's usually considered bad practice to put call code in events. Instead of running the click method from the textbox, put the code that's in the click method in a custom form method, and call it from both the textbox and button.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform