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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to compare 2 listviews and copy listview content to another listvi

Status
Not open for further replies.

Edward07

Programmer
Apr 13, 2007
49
NL
Hi all. I am filling a listview with xml data as shown in code beleow. I am calling this part using timer.What i want at the end of this code to compare listview1 with listview2. If they are diffrent or if listview2 is empty then i copy content of listview1 to listview 2.Otherwise do nothing. could any one show me how i can make such compare an copy?Thanks

Code:
Dim objDoc As MSXML2.DOMDocument
Dim objNodelist As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim lvwItem As ListItem


    'load the xml document
    Set objDoc = New MSXML2.DOMDocument
    objDoc.async = False
    objDoc.Load "[URL unfurl="true"]http://localhost/data.php"[/URL]
    
    'add all the song nodes into a  nodelist
    Set objNodelist = objDoc.selectNodes("//song")
    
    'Clear the listview
    ListView1.ListItems.Clear

    'Loop through each song node and add to the list view
    For Each objNode In objNodelist
        Set lvwItem = ListView1.ListItems.Add(, , objNode.selectSingleNode("artist").Text)
        lvwItem.SubItems(1) = objNode.selectSingleNode("name").Text
        lvwItem.SubItems(2) = objNode.selectSingleNode("image").Text
        lvwItem.SubItems(3) = objNode.selectSingleNode("rating").Text
        lvwItem.SubItems(4) = objNode.selectSingleNode("songid").Text
        lvwItem.SubItems(5) = objNode.selectSingleNode("totalvotes").Text

    Next objNode

''Here i want to compare listview1 with listview2. If it is empty or diffrent if fill it
otherwise i do nothing.
Set lvwItem = Nothing
    Set objNodelist = Nothing
    Set objDoc = Nothing
 
What you're describing is always having two identical copies of the same listview. Why can't you just always fill it whether it's identical or not?

Bob
 
Thank you for your reply. I am trying to reduce the number of listview reloading. I want to reload listview ONLY when i see its data is diffrent then the data that has just arrived. Could you help me with this probelm?
 
Ok, as I said in your other post (by the way, are you beginning to see why creating multiple threads about the same thing is a problem?) it looks more like you're concerned about the appearance of your application than its behavior. So, if the user can't see you reloading listview, then it's fine to reload listview.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top