Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moverlist - getting 2 columns over to selected list - how to? 1

Status
Not open for further replies.

ahaws

Programmer
Nov 28, 2001
355
US
Hi all-
I'm using a moverlist, and I can load the source list into 2 columns ( a description, and a unique key to find the description in a table)--however, when I select items from list1 to move over to list2, it only copies over the 1st column(description) of the source list, but the unique key field does not, so when I skip through the list2 box to gather the unique key into an array, I only have a description.

I was able to change the code around where when the list1 inits, the unique key is placed in column1 and the description in column 2:
With Thisform.moverlists1.lstSource
.ColumnWidths = "40,160"
.ColumnCount = 2
nRow = 0
Scan
If !Empty(keydesc.Desc)
nRow = nRow + 1
.AddListItem(STR(keydesc.primary,3),nRow,1)
.ListItem(nRow,2) = desc
Endif
Endscan
Endwith

But- when the user selects which items to move to list2, the unique number is the only thing shown in list2, and not the description...and I want the user to see the description.

I am using the moverlist from the samples directory. Is there anyway to change the columncount in list2 so I can reference it as I do for the source list?

Thanks
Angie


 
Hi,
This part of the code I use in my 'mover'
maybe you van tailor it to your wish ?
By the way:
-lstLeft holds items to selct
-lstRight holds th eselected items

-Bart

Local N As numeric, nColumn As numeric
With This.parent.lstLeft
nID = .ListItemId
If nID>0
For nColumn = 1 To .Columncount
This.parent.lstRight.AddListItem(.ListItem(M.nID,M.nColumn), M.nID, M.nColumn)
Next
.RemoveListItem(M.nID)
Endif
endwith
 
Hi Nifrabar-
Not quite sure where the IsLeft and IsRight methods are...

I think I have to modify the class somehow...

Thanks for your help though
Angie
 
Here is the code from the class for a single list item mover button:
nCnt = 1
Do While nCnt <= This.Parent.lstSource.ListCount

If This.Parent.lstSource.Selected(nCnt)
This.Parent.lstSelected.AddItem(This.Parent.lstSource.List(nCnt)
This.Parent.lstSource.RemoveItem(nCnt)
Else
nCnt = nCnt + 1
Endif
Enddo

I have tried to modify by replacing (nCnt) with
(nCnt,1)and addlistitem(nCnt,2):

This.Parent.lstSelected.AddItem(This.Parent.lstSource.List(nCnt,1)

This.Parent.lstSelected.AddListItem(This.Parent.lstSource.List(nCnt,2)


however, it want to move column 1 of source to row1 and column2 of source to row2...I want all in one row....

Any takers?
 
Ahaws,

Try this :
This.Parent.lstSelected.AddItem(This.Parent.lstSource.List(nCnt,1))
This.Parent.lstSelected.List(This.Parent.lstSelected.ListCount, 2) = (This.Parent.lstSource.List(nCnt,2))

Hope it works

-- AirCon --
 
Take a look at his FAQ. It shows an example with a single and multiple list item.

faq184-4322 Programmatically Loading & Referencing Listbox Items


Jim Osieczonek
Delta Business Group, LLC
 
The target list current item getting added is This.Parent.lstSelected.ListItemId, so try using something like:

This.Parent.lstSelected.AddListItem(This.Parent.lstSource.List(nCnt,1), This.Parent.lstSelected.ListItemId , 1)
This.Parent.lstSelected.AddListItem(This.Parent.lstSource.List(nCnt,2), This.Parent.lstSelected.ListItemId , 2)



-Dave S.-
[cheers]
Even more Fox stuff at:
 
Hi All-
AirCon-
Tried your suggestion first and that works great! Finally!
however, I modified the sample class and found another snag-

When I move the source to the selected list, though, I want to remove the second column from the source as well:

This.Parent.lstSource.RemoveItem(nCnt) only removes the ist column.

Would I just say:

This.Parent.lstSource.RemoveItem(nCnt,1)
This.Parent.lstSource.RemoveItem(nCnt,2)?



Thanks to both Jimoo and DSummZZZ as well for your help.
Angie
 
Also tried to modify the class where it moves 'all' from source to selected:
Here's the class code
For i = 1 To This.Parent.lstSource.ListCount
THIS.Parent.lstSelected.AddItem(THIS.Parent.lstSource.List(i))
Endfor

I tried to do this:
For i = 1 To This.Parent.lstSource.ListCount
THIS.Parent.lstSelected.AddItem(THIS.Parent.lstSource.List(i,1))
THIS.Parent.lstSelected.list((This.Parent.lstSelected.ListCount, 2) = (This.Parent.lstSource.List(i,2))
Endfor


I keep getting function, agrument, or count is invalid for this....I cant wait to be done with this! I can't believe this is whooping me...

Thanks in advance for your help.
 
ahaws,

Sorry, there was a typo last time (although it worked :). Try this:

For i = 1 To This.Parent.lstSource.ListCount
THIS.Parent.lstSelected.AddItem ;
(THIS.Parent.lstSource.List(nCnt, 1))
THIS.Parent.lstSelected.List ;
(THIS.Parent.lstSelected.ListCount, 2) = ;
THIS.Parent.lstSource.List(nCnt, 2)
THIS.Parent.lstSource.RemoveItem(nCnt)
Endfor


-- AirCon --
 
I got it! Works for all or single mover buttons from source to selected and back to source. Thanks for all your help.
Angie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top