Results 1 to 5 of 5

Thread: Get content of 2 listview

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    98

    Cool Get content of 2 listview

    hi
    Im having two user control on a same form that contains 2 listview. id like to take the content of 1 listview by usercontrol and put it in another listview

    im presently able to do the content of one listview in one user control but i dont know how to get the content of the second one in the other user control

    somebody have an idea ??

    here is the code for the content of the first listview :


    VB Code:
    1. For i = 1 To lvwAlarmList.ListItems.Count
    2.  Set itmx = lvwAlarmePrint.ListItems.Add(, , lvwAlarmList.ListItems.Item(i))
    3.      For j = 1 To lvwAlarmList.ColumnHeaders.Count - 1
    4.      itmx.SubItems(j) = lvwAlarmList.ListItems.Item(i).SubItems(j)
    5.     Next j
    6. Next i

    thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    98

    Exclamation Re: Get content of 2 listview

    Anybody has a little idea of how i could do this ??

  3. #3
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Get content of 2 listview

    Quote Originally Posted by DesyM
    hi
    Im having two user control on a same form that contains 2 listview. id like to take the content of 1 listview by usercontrol and put it in another listview

    im presently able to do the content of one listview in one user control but i dont know how to get the content of the second one in the other user control

    somebody have an idea ??

    here is the code for the content of the first listview :


    VB Code:
    1. For i = 1 To lvwAlarmList.ListItems.Count
    2.  Set itmx = lvwAlarmePrint.ListItems.Add(, , lvwAlarmList.ListItems.Item(i))
    3.      For j = 1 To lvwAlarmList.ColumnHeaders.Count - 1
    4.      itmx.SubItems(j) = lvwAlarmList.ListItems.Item(i).SubItems(j)
    5.     Next j
    6. Next i

    thanks
    If I am understanding your question correctly you want to copy the contents of Listview #1 into Listview #2 while taking the contents of Listview #2 and copy it into Listview #1? Is this correct? If this is what you are looking to do then you might want to put a third listview on your form and prior to copying the data from Listview #1 to Listview #2 you copy the data from Listview #2 to Listview #3 then copy Listview #1's data to Listview #2 and then copy Listview #3 to Listview #1 using your code:

    VB Code:
    1. For i = 1 To Listview2.ListItems.Count
    2.  Set itmx = Listview3.ListItems.Add(, , Listview2.ListItems.Item(i))
    3.      For j = 1 To Listview2.ColumnHeaders.Count - 1
    4.      itmx.SubItems(j) = Listview2.ListItems.Item(i).SubItems(j)
    5.     Next j
    6. Next i
    7.  
    8. For i = 1 To Listview1.ListItems.Count
    9.  Set itmx = Listview2.ListItems.Add(, , Listview1.ListItems.Item(i))
    10.      For j = 1 To Listview1.ColumnHeaders.Count - 1
    11.      itmx.SubItems(j) = Listview1.ListItems.Item(i).SubItems(j)
    12.     Next j
    13. Next i
    14.  
    15. For i = 1 To Listview2.ListItems.Count
    16.  Set itmx = Listview3.ListItems.Add(, , Listview2.ListItems.Item(i))
    17.      For j = 1 To Listview2.ColumnHeaders.Count - 1
    18.      itmx.SubItems(j) = Listview2.ListItems.Item(i).SubItems(j)
    19.     Next j
    20. Next i

    I haven't tested this code but it should work.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    98

    Re: Get content of 2 listview

    the only problem that ive got is that my listviews are notre on the same user control,,,,so i can only read one listview...so i try to understand how can i tell that im on usercontrol 1 or usercontrol2

    thanks

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Get content of 2 listview

    Quote Originally Posted by DesyM
    the only problem that ive got is that my listviews are notre on the same user control,,,,so i can only read one listview...so i try to understand how can i tell that im on usercontrol 1 or usercontrol2

    thanks

    Could you post your code or zip up the project, so I can try to understand what you are looking to do.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width