How to update listview ONLY when new data is avilable in vb6?
-
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 similar 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 focus on the form and i see many unnecessary refreshes!! Could any one show me a better solution to avoid these unnecessary refreshes?I know these professional applications are using a method that i am not aware of.Thanks
-
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 similar 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 focus on the form and i see many unnecessary refreshes!! Could any one show me a better solution to avoid these unnecessary refreshes?I know these professional applications are using a method that i am not aware of.Thanks
The solution is surprisingly simple and you use them every day. They're called "events". If you break your application into seperate layers for UI, business logic, and data, the opportunity to create your own events that signal changes in the data becomes clear. Then all you have to do is subscribe to those events in your UI code and you've got your solution.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
The solution is surprisingly simple and you use them every day. They're called "events". If you break your application into seperate layers for UI, business logic, and data, the opportunity to create your own events that signal changes in the data becomes clear. Then all you have to do is subscribe to those events in your UI code and you've got your solution.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Dave thank you for reply.I am not very experienced vb6 developer.So i need some more information about this process. In my case i have a listview that it gets data from a dynamic xml file. I use timer to re populate the listview every few seconds. Obviously this cause lots of flicking and lose of form focus and i see lots of unnecessary listview reloads. Could you consider this case and let me know how to reload listview ONLY when new data has arrived. I have seen it many applications doing that but don't know how they do it!! Looking forward for some examples.Thanks
-
Dave thank you for reply.I am not very experienced vb6 developer.So i need some more information about this process. In my case i have a listview that it gets data from a dynamic xml file. I use timer to re populate the listview every few seconds. Obviously this cause lots of flicking and lose of form focus and i see lots of unnecessary listview reloads. Could you consider this case and let me know how to reload listview ONLY when new data has arrived. I have seen it many applications doing that but don't know how they do it!! Looking forward for some examples.Thanks
Since you're reading from an XML file every few seconds, there isn't a simple solution to this. You'd have to implement your own method of detecting changes in the file, like checking the Modified date/time on the file, in order to fire the event.
method007 wrote:
Looking forward for some examples
I don't have any.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007