Transfering data in a listview box to another listview box

Hey Experts

I am making a software application for a salon company and I am using listview boxes to add products and services to the bill.

The problem is i dont know how to transfer the information stored in the listview box in frmProducts to the listview box in frmService and vice versa

Thank you

Northern_Lights
Nothern_LightsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iHadiCommented:
Try the following code:

Dim lItem As ListItem
ListView2.ListItems.Clear
For Each lItem In frmProducts.ListView1.ListItems
    frmService.ListView2.ListItems.Add lItem.Index, lItem.Key, lItem.Text, lItem.Icon, lItem.SmallIcon
Next
Nothern_LightsAuthor Commented:
Hey iHadi

VB says that lItem is blank i have changed the code and it is now

Dim litem As ListItem
For Each litem In frmProducts.lstBill.ListItem
    FrmService.lstBill.ListItems.Add litem.Index, litem.Key, litem.Text, litem.Icon, litem.SmallIcon
Next

the code is in FrmService_FormLoad

Thanks

Nothern_Lights




vinnyd79Commented:
Try something like this:

Dim litem As ListItem
Dim x As Long
FrmService.lstBill.ListItems.Clear
For x = 1 To frmProducts.lstBill.ListItems.Count
    Set litem = FrmService.lstBill.ListItems.Add(, , lstBill.ListItems.Item(x))
Next x
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

vinnyd79Commented:
I meant:

Dim litem As ListItem
Dim x As Long
FrmService.lstBill.ListItems.Clear
For x = 1 To frmProducts.lstBill.ListItems.Count
    Set litem = FrmService.lstBill.ListItems.Add(, , frmProducts.lstBill.ListItems.Item(x))
Next x
vinnyd79Commented:
The above will transfer the item in the first column. To transfer subitems you would do somethong like this:

Dim litem As ListItem
Dim x As Long
FrmService.lstBill.ListItems.Clear
For x = 1 To frmProducts.lstBill.ListItems.Count
    Set litem = FrmService.lstBill.ListItems.Add(, , frmProducts.lstBill.ListItems.Item(x)) ' col 1
    litem.SubItems(1) = frmProducts.lstBill.ListItems.Item(x).SubItems(1) ' col2
    litem.SubItems(2) = frmProducts.lstBill.ListItems.Item(x).SubItems(2) ' col3
Next x

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nothern_LightsAuthor Commented:
Thank You very much vinnyd79 the code worked perfectly
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.