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?
 
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
0
 
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
0
 
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




0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
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
0
 
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
0
 
Nothern_LightsAuthor Commented:
Thank You very much vinnyd79 the code worked perfectly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.