Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reordering a listbox
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00627651
Message ID:
00628644
Vues:
15
Hiya Tommy...

I have a listbox class which I use to reorder things... here is an excerpt.

*-- I have a form property called lahold1ar(1) blank array for a form to hold only one column of data... assume only one item in the listbox... you can have more by increasing the array property number.. I generally have lahold1ar, lahold3ar(3,0) and lahold5ar(5,0) and use them only when needed... (bad form? don't know lol... but I inherited this app)

**-- let us assume we now have reordered the contents of the listbox, so - I have a method of the listbox class I call checkforneworder()...

*-- this is based on the fact you are putting the list in initially by hand.... and that you turn the 'sorted' off...

EXAMPLE 1 - the user has reorderd the list by hand using the movers....
*-- mylistbox.CheckForNewOrder

 DIMENSION mylistbox.lanewlist(1)

 FOR ii = 1 TO mylistbox.ListCount
  DIMENSION myform.lanewlist(ii)
  myform.lanewlist(ii) = mylistbox.List(ii)
 NEXT
 mylistbox.clear()

 *... now you can put the items back in... they will be in order:

 FOR kk = 1 TO ii
  mylistbox.AddListItem(myform.lanewlist(ii))
 ENDFOR
EXAMPLE 2 - the user wants to reorder based on selected items...
*-- mylistbox.CheckForNewOrder

 DIMENSION mylistbox.lanewlist(1)

 FOR ii = 1 TO mylistbox.ListCount
  *-- First, put the selected items in first
  IF mylistbox.Selected(ii)
    DIMENSION myform.lanewlist(ii)
    myform.lanewlist(ii) = mylistbox.List(ii)
  ENDIF
 NEXT

  *-- Now, put the unselected items in
 FOR ii = 1 TO mylistbox.ListCount
  IF !(mylistbox.Selected(ii))
    DIMENSION myform.anewlist(ii)
     myform.lanewlist(ii) = .lst_selected.List(ii)
  ENDIF
 NEXT
 mylistbox.clear()

 *... now you can put the items back in... they will be in order:

 FOR kk = 1 TO ii
  mlistbox.AddListItem(myform.lanewlist(ii))
 ENDFOR
HTH


Ric

>Is there a way to programatically change the order that things show up in a listbox?
>
>I am using the listbox and populating it manually so I can use the mover bars. I am saving the data successfully but I need to restore it a little differently.
>
>If the user selects multiple items from the list when I populate the list next time i need to order the items that were saved before to the top of the list.
>
>I tried setting Index, etc... but have had no luck.
>
>Thanks in advance for any help.
>
>Tommy
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform