Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Listbox programmatically select & highlight
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01515590
Message ID:
01516600
Vues:
179
>I have a listbox.
>
>I want to preselect items in the listbox in the Init method of my form. the MultiSelect property is .T.
>
>I populate the listbox with a cursor, and then set individual Selected(i) = .T., for one or more entries.
>
>This appears to actually cause those items to be selected, but the selections lack the blue highlighting.
>
>When the user then clicks on items, the items clicked on do highlight.
>
>How do I get the programmatically selected items to appear highlighted.
>
>Thanks,
>Jim

I finally got this working, but I am not sure why.

I previously was populating the listbox using a cursor (RowSourceType = 2-Alias). I tried that in the form init method but also in the listbox init method. I selected items in the listbox in the form Init method, listbox init, and probably some other places. But none of this worked.

What finally worked was to populate the grid using AddItem methods in a scan loop using the same cursor. RowSourceType = 0-None. I located this code in the listbox Init method. pre-Selection of items in the listbox continues to be the form Init method.

This works: when the form comes up, the pre-selected items in the listbox are highlighted.

Thanks to Naomi, Koen, and Hugo for taking the time to consider my problem and posting suggestions.

Jim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform