Efficiently populating a listview

Recommended Posts

mark2004 0

mark2004 0

I have a listview that I must populate with sometimes upwards of 2000 items. I am doing it with GUICtrlCreateListViewItem and

it takes a huge amount of time (maybe 10 seconds). The listview has 3 columns so I don't think I could just create a long delimited string and use that in the GUICtrlCreateListView command. Or maybe I could, I just don't know how.

If anyone knows of a way to speed this process up, I'd love to learn it!!!

Thanks.

Share this post

Link to post

Share on other sites

martin 73

martin 73

I have a listview that I must populate with sometimes upwards of 2000 items. I am doing it with GUICtrlCreateListViewItem and

it takes a huge amount of time (maybe 10 seconds). The listview has 3 columns so I don't think I could just create a long delimited string and use that in the GUICtrlCreateListView command. Or maybe I could, I just don't know how.

If anyone knows of a way to speed this process up, I'd love to learn it!!!

Thanks.

I haven't tried this but it might be that the reason it takes a long time is that every time you add an item the listview gets redrawn. I've had this problem with text boxes.

To see if this is the reason you could try making it invisible, add the items, then make it visible again.

Also, make sure you haven't got LVS_SORTASCENDING or LVS_SORTDESCENDING set when you are adding items because this takes up a lot of time.

Share this post

Link to post

Share on other sites

mark2004 0

mark2004 0

Well, the hide/show trick speeds it up considerably. Gets it down to maybe 4-5 seconds. I do have the $LVS_SORTASCENDING style set for this listview BUT I actually need the items to be sorted. Is there a way to turn off this style temporarily while I'm populating the listview and then turn it back on when I'm done so that it is only sorted once???

I'd love to get this down to less than a second but I don't know If I'm asking too much......

Share this post

Link to post

Share on other sites

Zedna 200

Zedna 200

Well, the hide/show trick speeds it up considerably. Gets it down to maybe 4-5 seconds. I do have the $LVS_SORTASCENDING style set for this listview BUT I actually need the items to be sorted. Is there a way to turn off this style temporarily while I'm populating the listview and then turn it back on when I'm done so that it is only sorted once???

I'd love to get this down to less than a second but I don't know If I'm asking too much......

I used ListView many times in my projects and instead of $LVS_SORTASCENDING style I prepared data into global $data[] array. This array can be sorted by _ArraySort().

I tried that and it 8.6 seconds for me. Maybe it's XP- I'm surpised you get that speed if the only difference is you using WIn98 unles it's my CPU which is a Celeron 2.4 GHz and 512Mb Ram
Edited December 31, 2006 by martin

Share this post

Link to post

Share on other sites

martin 73

martin 73

Do you have latest version of AutoIt? In version 3.2.2.0 is done speed improvement (about 100% in some scripts)

Also check for some background processes in WinXP and their CPU consuming - maybe antivirus/firewall or something similar.

I have tried with version 3.2.2.0 and beta 3.2.1.14 and there is no difference in speed for me. If I look at the Task Manager the System Idle Process is around 98,99%. When I run the script and click on Paid Cases it takes up 99% of the CPU time while its filling the listview so I don't know how you go so fast!

I have also tried compiling and running the exe rather than running from Scite but again no difference.

Incidentally, I notice that you cannot tell the version of Autoit2exe; it just says version 3. This is an omission isn't it?