Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
List box: Distorted transfer from one to another
Message
De
13/01/2005 06:03:22
 
 
À
13/01/2005 02:22:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00976674
Message ID:
00976699
Vues:
22
Steven

I haven't seen your code but one thing you've got to watch out for is that the .ListCount changes as you add and remove.
This works for me, and in many applications (note the buttons are in the same container as the listboxes)
* cmdRemove.Click() - i.e. the single back-arrow button (<)

LOCAL	lnListCount

THISFORM.LockScreen 	    = .T.
nCnt = 1
With This.Parent
   DO WHILE nCnt <= .lstSelected.ListCount
	 IF .lstSelected.Selected( nCnt)
	 	lnListCount  = .lstSource.ListCount + 1
		.lstSource.AddListItem( .lstSelected.List( nCnt, 1), lnListCount, 1)
		.lstSource.AddListItem( .lstSelected.List( nCnt, 2), lnListCount, 2)
		.lstSelected.RemoveItem( nCnt)
	 ELSE
		nCnt 	    = nCnt + 1
	 ENDIF
  ENDDO
EndWith
THISFORM.LockScreen = .F.
* cmdRemoveAll (<<)

THISFORM.LockScreen 		= .T.
FOR nCnt = 1 to THIS.Parent.lstSelected.ListCount
	THIS.Parent.lstSource.AddListItem( THIS.Parent.lstSelected.List( nCnt, 1), nCnt, 1)
	THIS.Parent.lstSource.AddListItem( THIS.Parent.lstSelected.List( nCnt, 2), nCnt, 2)
ENDFOR
THIS.Parent.lstSelected.Clear
THISFORM.LockScreen 		= .F.
But the add buttons do it differently from yours:
* cmdAdd.Click() (>)
LOCAL	lnListIndex

THISFORM.LockScreen 		= .T.
* The ListCount value changes whenever the RemoveItem method is called
nCnt = 1
With This.Parent
  lnListIndex			= .lstSelected.ListCount
  DO WHILE nCnt <= .lstSource.ListCount
	  IF THIS.Parent.lstSource.Selected(nCnt)
		  lnListIndex 	= lnListIndex + 1
		  .lstSelected.AddListItem( .lstSource.List( nCnt, 1), lnListIndex, 1)
		  .lstSelected.AddListItem( .lstSource.List( nCnt, 2), lnListIndex, 2)
		  .lstSource.RemoveItem( nCnt)
	  ELSE
		  nCnt 		= nCnt + 1
	  ENDIF
  ENDDO
EndWith
THISFORM.LockScreen = .F.
* cmdAddAll.Click() (>>)
THISFORM.LockScreen = .T.
FOR nCnt = 1 to THIS.Parent.lstSource.ListCount
	THIS.Parent.lstSelected.AddListItem( THIS.Parent.lstSource.List( nCnt, 1), nCnt, 1)
	THIS.Parent.lstSelected.AddListItem( THIS.Parent.lstSource.List( nCnt, 2), +nCnt, 2)
ENDFOR
THIS.Parent.lstSource.Clear
THISFORM.LockScreen = .F.
HTH

Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform