views:

194

answers:

1

If I'm using a ListView in virtual mode then, as I understand it, the list view only keeps track of a small number of items in the list. As the user scrolls it dynamically retrieves items it needs to show from the virtual list.

But what if an item is added or removed from the master list? If an item is added/removed outside of the range of indexes being shown by the list view then I would assume the list view would show the added/missing items when the user scrolls to that index. Is this correct? But what if an item is added/removed from the range of indexes the user is currently viewing? How do I trigger the list view to refresh the items it is currently viewing to show the new/missing items?

FYI: I'm using an ObjectListView if that makes any difference.

+2  A: 

A virtual list knows nothing about your list of items. It doesn't keep track of them, not even a small set. It only ever asks "what do you want to show at the n'th row?"

If your master list changes, all you need to do is redraw the list. Invalidate() will do that for you. The listview will then ask you again what it should show at every row visible in the control.

If you are using ObjectListView, have you considered using the FastObjectListView which gives you the speed benefits of a virtual list and the ease of use of a normal ObjectListView?

Grammarian
I'm loading individual thumbnails for each item in the list so I need to be notified when the user is viewing each item so I can preload the thumbnails. I'm trying to avoid loading all the thumbnails at once as I could potentially be showing a large number of items. Currently I am calling Build() to update the VirtualLIstView when my collection changes. Is there a reason I would want to call Invalidate() over Build()?
Eric Anastas
A virtual list is exactly the right approach to do what you want -- I've used exactly the same strategy. And BuildList() is best -- it call Invalidate() as part of its processing. Does it work?
Grammarian