Question about best practices when using ListView in VirtualMode

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am working on an app which - for a given period of time - frequently
receives messages in background thread (every 2-5 ms). These messages are
then translated and should be sent/added to ListView. I understand that I
should use VirtualMode here because there will for sure be a huge number of
messages. What I am not sure about is the following:
1) The total number of items is unknown. Can I dynamically change
VirtualListSize property without any drawback?
2) How can I force ListView to keep rolling its visible part up, as messages
are being received?
3) What would be the best option for underlying store/array? Perhaps
ArrayList and ArrayList.Add() method ?

Thanks !
 
Rostislav said:
2) How can I force ListView to keep rolling its visible part up, as
messages
are being received?

'ListView.EnsureVisible', 'ListViewItem.EnsureVisible'.
3) What would be the best option for underlying store/array? Perhaps
ArrayList and ArrayList.Add() method ?

I'd use a generic list, 'List(Of T)' for example.
 
Herfried,
thanks for your tips. It works for me now, and it can easily handle
1,000,000+ of entries. One interesting side note: I also had to implement
filter in my virtual list, based on some attributes, and I faced an exception
issue when changing VirtualListSize value and redrawing ListView. Following
code works in case VirtualListSize is getting bigger (for example when
resetting the filter):
listView1.VirtualListSize = decodeMsgsCounter;
listView1.EnsureVisible(0);
But it can blow up the app in case VirtualListSize is getting smaller.
After playing with that for a while I found pretty simple trick which seems
to fix the whole problem:
listView1.EnsureVisible(0);
listView1.VirtualListSize = decodeMsgsCounter;

Rostislav
 
Back
Top