Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MultiCoolumn MoverListBox
Message
De
12/09/1997 10:50:24
Dave Emerson
Dc Emerson Consult8Ng, Inc
Destin, Floride, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00049176
Message ID:
00049842
Vues:
68
>>>>Has anyone found the key to moving an item from one listbox to another if the item is a multicolumn item.
>>>>
>>>>When I try to move each column (3) separately using the AddItem method, the moved to listbox has 3 new items. What I want is 1 new item with the 3 columns.
>>>>
>>>>I checked the Solutions sample code, but that only uses 1 column.
>>>>
>>>>TIA,
>>>>Dave Emerson
>>>
>>>Dave, read the Help for AddItem and form AddListItem. They show how to use the index of the new item to then add information to the other columns. You may need a separate command for each column.
>>>
>>>Barbara
>>
>>Using the AddItem method with the next available index is what I have done. Here is the code from the InteractiveChange method of the available list placing the selected item into the selected list:
>>
>>iCnt = This.ListIndex && the index of the selected item in the available list
>>lnListCount = ThisForm.lstSelected.ListCount+1 && the next index in the selected list
>>ThisForm.lstSelected.AddItem(This.List(iCnt,1),lnListCount,1) && the first column
>>ThisForm.lstSelected.AddItem(This.List(iCnt,2),lnListCount,2) && second
>>ThisForm.lstSelected.AddItem(This.List(iCnt,3),lnListCount,3) && third
>>
>>Each AddItem adds an item to the appropriate column, but into the same row number, eg. 1. As the help for AddItem says, "If you specify an nIndex that already exists, the item is inserted at that position and all items below that item are moved down one position in the list portion of the ComboBox or ListBox control." As a result each column gets added to row 1 and any item already present gets pushed down a row. Furthermore, the last item gets added to column 1 as well as colum 3. The resulting list looks like this:
>>
>>third column value third column value
>> second column value
>>first colum value
>>
>>See my exasperation?
>>Dave
>
>Dave,
>Yes, I'd be exasperated too. Try this instead:
>
>cVal = "Next Item"
>Thisform.list1.additem(cVal+'a') && Adds into Column 1, next row
>nCnt = thisform.list1.newitemid && Finds out the ItemID just added
>thisform.list1.list( nCnt, 2)= cVal + 'b' && Adds to the second column
>thisform.list1.list(nCnt, 3) = cVal + 'c' && Adds to the third column
>
>thisform.list1.requery && You knew this one :-)
>
>This should give you what you need. AddItem, as you discovered, only adds new rows, but you can access the rest of the columns with the list() method, as long as you know what the ItemID is.
>
>Sorry I didn't get back to you sooner, but I needed to test this.
>
>Barbara

Barbara,

You're a genius!!! Thanks, that worked.

I had built a work-around using a concatenated field array, but this is faster, neater and a lot easier to maintain.

Thanks, again.

Dave
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform