FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
List box question
List box question
Débuté par Sammy Broeders, 21 aoû. 2018 13:12 - 7 réponses
Connectez-vous…
Sammy Broeders
#1
Posté le 21 août 2018 - 13:12
Hello all,
I have a list box filled with a data file, now i want to select one or more items in this list box and delete it from this list box/datafile to another list box/datafile. I use the code below but it is not working ok, most of the time other rows who are not selected converted to the other listbox.
FOR EACH SELECTED ROW OF LIST_all
HReadSeek(VoertuigSoort,Nummer,LIST_all)
VoertuigSoortGroep1 = VoertuigSoort
HAdd(VoertuigSoortGroep1)
HDelete(VoertuigSoort)
END
ListDisplay(LIST_all)
ListDisplay(LIST_filter1)
Signaler
0
0
Piet van Zanten
#2
Posté le 21 août 2018 - 20:46
Hi Sammy,
If you delete stuff in a for each loop, you always have to do it in reverse order FOR Each xxx FromEnd, otherwise the delete will interfere with the browse.
And do a listdisplay(xxx, taInit) afterwards.
Kind regards,
Piet
Signaler
0
0
Sammy Broeders
#3
Posté le 22 août 2018 - 18:46
Thanks Piet,
But where can i place ''fromend'' ?
Sammy
Signaler
0
0
DW
#4
Posté le 22 août 2018 - 20:26
Sammy
something like this:
//Get the count of selected rows nCount is int = TableSelectCount(TABLE_Orders) nRow is int //Make sure you have at least 1 row IF nCount > 0 THEN //Now we step form back to front of the table FOR i = nCount TO 1 STEP -1 //Select the last row first and move 1 by 1 to the first nRow = TableSelect(TABLE_Orders,i) //Do your magic here END END END ELSE Info("You must select at least one row to preform this operation! ") END
DW
Signaler
0
0
Piet van Zanten
#5
Posté le 22 août 2018 - 22:03
Hi Sammy,
I see now that there is no FromEnd for "FOR EACH Selected".
A very simple solution would be to gather the IDs first:
ar_Selection is array of int FOR EACH SELECTED ROW OF LIST_all ArrayAdd(ar_Selection,LIST_all) END FOR EACH ID OF ar_Selection HReadSeek(VoertuigSoort,Nummer,ID) VoertuigSoortGroep1 = VoertuigSoort HAdd(VoertuigSoortGroep1) HDelete(VoertuigSoort) END ListDisplay(LIST_all) ListDisplay(LIST_filter1) Kind regards,
Piet
Signaler
0
0
Sammy Broeders
#6
Posté le 23 août 2018 - 11:41
Piet,
Your first solution works ok, the second post gives the same problem as i had.
Thanks
Signaler
0
0
Piet van Zanten
#7
Posté le 23 août 2018 - 14:49
Hi Sammy,
You probably mean DW's solution or did the FromEnd work?
Just wondering: is the list a simple list or is it a list with a returned value?
IOW, does it return the list index or the linked value?
Kind regards,
Piet
Signaler
0
0
Sammy Broeders
#8
Posté le 24 août 2018 - 16:50
Sorry your right, i mean DW`s solution.
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte