Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2006

Tip: Looking for answers? Try searching our database.

ListView loading slowly

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 23 Jun 2006 01:14 GMT
I am loading a ListView like this...

    foreach (DataRow dr in dt.Rows)
     {
       ListViewItem lvi= new ListViewItem((string)dr["field1"]);
       lvi.Tag = (string)dr["field2"];
       listviewTest.Items.Add(lvi);
     }

The DataTable is large and the ListView takes a long time to load.  What can
I do to speed this up?

TIA

David
Tim Wilson - 23 Jun 2006 02:18 GMT
Try using the BeginUpdate/EndUpdate methods.

Signature

Tim Wilson
Device Application Development MVP

>I am loading a ListView like this...
>
[quoted text clipped - 11 lines]
>
> David
Marc Gravell - 23 Jun 2006 08:47 GMT
Also - try (in the loop) adding the new ListViewItem objects to a
List<ListViewItem> - then at the end call
.Items.AddRange(yourList.ToArray()); - this reduces the number of calls into
the list view; supprounding this last call with BeginUpdate / EndUpdate may
also help, but if you are only making one call I would expect it to handle
that internally without painting each time... but best to be paranoid and
use them anyway ;-p

Marc
James - 23 Jun 2006 12:50 GMT
hi David,
  please load your listview in load function of your control/Form. Use
BeginUpdate /EndUpdate. Use of Double buffering in your list view
might increase performance a little bit. if your listview  contains
large number of itmes then use Virtual Listview Mode. the main problem
comes of flickering  is also when the columns are resized. So better,
hook its  paint events in Wndproc.
Hope this helps. :)

James

> I am loading a ListView like this...
>
[quoted text clipped - 11 lines]
>
> David
David - 24 Jun 2006 14:15 GMT
Hi James,

What is Virtual ListView Mode?  I have read about a virtual ListView
control.  I have considered it - looks like I would have to write it in C++
and would require more time.

Thanks.

David

> hi David,
>   please load your listview in load function of your control/Form. Use
[quoted text clipped - 23 lines]
>>
>> David
David - 24 Jun 2006 14:22 GMT
Thanks Everyone, for the suggestions...

I am not necessarily wedded to the ListView.  I need to do tests next week
when I get some time.  A ListBox would do, which I suspect would be lighter
weight, and I could use data binding.  Also, I am wondering if a DataGrid
would be more optimized than the ListView.

Any thoughts on the above?

David

>I am loading a ListView like this...
>
[quoted text clipped - 11 lines]
>
> David

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.