Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Remove items from List Box
Message
De
09/06/2007 17:30:57
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
09/06/2007 16:59:32
Randy Hooper
Ranco Business Software
Tampa, Floride, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01231800
Message ID:
01231802
Vues:
19
>How can I move item(s) from a list box campare to my table?
>
>this code is in a command button.
>
>
>for i = 1 to thisform.list2.listCount
>   go top
>   locate for alltrim(categoryPick) == alltrim(thisform.list2.list(i))
>   if !found()
>     thisform.list2.removeItem(thisform.list2.listIndex)
>   endif
>endfor
>
This should work, but you need to go backwards, i.e.

for i = thisform.list2.listCount to 1 step -1

because when you remove the nth list element, the list is shorter by one - then the n+1st element is what at the loop start was actually n+2nd. Going backwards gives the effect that anything you've deleted is behind you, you won't step over it again.

The simpler way would be to just base the listbox on a cursor derived from your table (even if just a single-field one), and repopulate the cursor in listbox's .requery(). That way you don't need any loops to match listbox with the table - you pull what you need from the table and tell the listbox to use it.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform