Skip to content

How to update listview ONLY when new data is avilable?

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #187932
    method
    Member

    Hi all. I have seen many applications that listview ONLY updates when new data is avilable or when current data changes. I am making an application that deals with similer case. But i don’t know how these applications achive this task. I tried to use timer to refresh my listview every few seconds(I am loading data from dynamic xml to listview.)But there is a big problem that i keep losing focouse on the form and i see many unessary refreshes!! Could any one show me a better solution to avoid these unessry refreshes?I know these profitional applications are using a method that i am not aware of.Thanks

    #187953
    Admin
    Administrator
    If rss  listview then
    refresh
    End If

    Tried that?

    #187952
    method
    Member

    ghoast . Could you explain to me how to use that and how it works? I never seen it before :-(( . Acutally the dynamic data is not rss. It is just dynamic xml generated from remote mysql)

    #187951
    Departure
    Member

    ghost wrote if rss is diffrent from listview then call the refresh function

    #187950
    Admin
    Administrator

    Yep, exactly what Dep said…

    All it’s doing is comparing the XML with the listview and seeing if they’re the same. If they’re not, then, like Dep said, it calls the function to refresh. I just put “refresh” in there because I figured it’d be easier to understand 😛

    Hope you understand it now…

    #187949
    method
    Member

    Thanks for both of you. ok. So how to compare rss with current listview? i posted my simple xml that is generated by php



    artistname1
    artistname1
    image1.gif
    2028574083
    566
    09898



    artistname2
    artistname2
    image2.gif
    2028574083
    566
    09898

    ...
    #187948
    Admin
    Administrator

    What’s outputting to the listview? The whole XML file? Like, the artist, name, image, etc.? Or is it just the name of the song?

    #187947
    method
    Member

    The whole xml file.

    #187946
    autopilot
    Member

    what I would do, is more like this

    If rss  rsscopy Then
    rsscopy = rss
    refreshlistview
    End If
    #187945
    Admin
    Administrator

    @autopilot wrote:

    what I would do, is more like this

    If rss  rsscopy Then
    rsscopy = rss
    refreshlistview
    End If

    That’s exactly what I was going to tell him to do next. Make a second, hidden listview and check it against the one displayed.

    #187944
    method
    Member

    @Ghost wrote:

    @autopilot wrote:

    what I would do, is more like this

    If rss  rsscopy Then
    rsscopy = rss
    refreshlistview
    End If

    That’s exactly what I was going to tell him to do next. Make a second, hidden listview and check it against the one displayed.

    Thanks for your suggestion .So if i need make to make a new listview do you think this line :If rss rsscopy
    will do the compar? rss and rsscopy are listview names? If not . could any one show me how to compare them?

    #187943
    Admin
    Administrator

    No, rss and rsscopy are what you’ve named the listviews. If you’ve named them rss and rsscopy, then yes, that’ll work. Otherwise, it’s whatever you’ve named them. Does that make sense?

    #187942
    autopilot
    Member

    rss & rsscopy are the names of xml files… rss is the source xml and rsscopy would be a copy of rss… if those are the names of the xml files, then the if statement should work to compair the 2 xml files.

    autopilot

    #187941
    Admin
    Administrator

    Oh, you’re doing it that way. I was thinking of loading the xml files into the program first… Autopiolt’s way would probably use less CPU, thus making it better. 😛

    #187940
    method
    Member

    @Ghost wrote:

    Oh, you’re doing it that way. I was thinking of loading the xml files into the program first… Autopiolt’s way would probably use less CPU, thus making it better. 😛

    This is how i populate my listview. How to compare it with old listview data?I am totaly lost with your replies:-(

    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 “http://localhost/xmloutput.php”

    ‘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

Viewing 15 posts - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.