Listview adding items

  • Thread starter Thread starter Shishir
  • Start date Start date
S

Shishir

Hi,

In an application for pocket pc, I add 100+ items dynamically to a
list view. However using the add() method in listview takes 15 seconds
to add these items using a loop. Do you know any faster way of adding
items ?

Regards
Shishir
 
Are you using BeginUpdate() and EndUpdate() around your loop, like in the
following pseudo-code?

listView1.BeginUpdate();
..
..
..
// Loop through adding items to the listview
..
..
..
listView1.EndUpdate();

--Neil

--
Neil Cowburn
Technologist
Microsoft Windows Embedded MVP
Content Master Ltd.

www.contentmaster.com | www.opennetcf.org
 
Yes actually I am already using beginupdate and endupdate. That does
improve the speed. Is there any way to further improve the speed,
since 15 seconds for 100 items is a noticable loading time ?

One way I can think of is to avoid reloading the list.
 
which device do you have?
When i fill 100 items into a listview with begin/EndUpdate i will take <15
sec on a HP iPaq2210

i do something like this:

lv1.BeginUpdate

...in a loop:
ListViewItem item = new ListViewItem();
item.Text = "something";
item.SubItems.Add("Something else");
lv1.Items.Add(item);

lv1.EndUpdate;

and i would recommend to do a Try/finally like this:

lv1.BeginUpdate;
try
{
...fill the listview
}
finally
{
lv1.EndUpdate;
}

otherwise you won't see anything (and never again) when the filling-code is
crashed.

Boris
 
Back
Top