Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Let the 1st item in a combobox have the focus
Message
De
08/03/2007 10:13:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01201705
Message ID:
01201907
Vues:
18
thisform.mycombobox1.Selected(1)=.t.
thisform.mycombobox1.Setfocus


I assume that you are trying to do this in the init() of the form. That will not work and it is documented in the KB:

PSS ID Number: 161730

Article Last Modified on 10/16/2002

--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Visual FoxPro for Windows 5.0
Microsoft Visual FoxPro for Windows 5.0a
Microsoft Visual FoxPro for Windows 6.0
--------------------------------------------------------------------------------

This article was previously published under Q161730

SYMPTOMS
In Visual FoxPro 3.0 the selected item in a list box can be initialized by placing the following code in the Form Init or the List box Init:
THISFORM.List1.Selected(1) = .T.

This does not work in Visual FoxPro version 5.0.

RESOLUTION
Place the following code in the Activate method of the form. The variable acts like a switch so that the code is executed only when the form is first instantiated. The variable switch should be added to the form as a property. Switch is initialized to false.
IF !THISFORM.switch
THISFORM.List1.Selected(1)= .T.
THISFORM.switch = .T.
ENDIF

BTW, their resolution is a crappy one. If you set foxus to the listbox before setting .selected( 1 ) = .T., your code would work, but a better solution is to set the listbox's ListIndex to 1.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform