|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
inserting Items in Listview too slowHi,
I need to insert thousands (up to 50000) of items taken from a Database into a ListView control. But this happens to be too slow. Constructing all the items and putting them into an array is pretty fast (split second). But when adding the Items with ListView.Items.AddRange(itemArray) it takes 10 seconds for 37000 items on my machine (Athlon XP 1700+ 768MB Ram). Is there a way to speed the task up, or does anyone know an alternative widget which has basically the same functionality (multi column view with sorting capabilities for each column). Regards Stephan Stephan, putting that many items into list-type controls is generally
considered to be a bad idea for a variety of reasons, some due to performance both on the database and on the control, some due to the awkwardness of the user interface from the perspective of the person running the application. You're seeing the worst part of the performance equation. You should consider developing a paging scheme so that you can load into the control a more reasonable number of items. You might go ahead and cache the dataset with all the records, and then page your way through it with forward and back buttons on the page or form. HTH, Tom Dacon Dacon Software Consulting Show quote "Stephan Zaubzer" <stephan.zaub***@schendl.at> wrote in message news:uWpyYRNKGHA.3272@tk2msftngp13.phx.gbl... > Hi, > I need to insert thousands (up to 50000) of items taken from a Database > into a ListView control. But this happens to be too slow. Constructing all > the items and putting them into an array is pretty fast (split second). > But when adding the Items with ListView.Items.AddRange(itemArray) it takes > 10 seconds for 37000 items on my machine (Athlon XP 1700+ 768MB Ram). > Is there a way to speed the task up, or does anyone know an alternative > widget which has basically the same functionality (multi column view with > sorting capabilities for each column). > Regards > Stephan Wrap your insert logic inside of a BeginUpdate and End Update method:
listView1.BeginUpdate(); // insert rows here listView1.EndUpdate(); Show quote "Stephan Zaubzer" <stephan.zaub***@schendl.at> wrote in message news:uWpyYRNKGHA.3272@tk2msftngp13.phx.gbl... > Hi, > I need to insert thousands (up to 50000) of items taken from a Database > into a ListView control. But this happens to be too slow. Constructing all > the items and putting them into an array is pretty fast (split second). > But when adding the Items with ListView.Items.AddRange(itemArray) it takes > 10 seconds for 37000 items on my machine (Athlon XP 1700+ 768MB Ram). > Is there a way to speed the task up, or does anyone know an alternative > widget which has basically the same functionality (multi column view with > sorting capabilities for each column). > Regards > Stephan |
|||||||||||||||||||||||