I need to delete all items from a treeview control. I've tried the TVM_DELETEITEM
message but thats too slow. Is there a better or faster way to do this?
Posted on 2003-12-07 09:16:48 by Odyssey
Maybe you could delete the old TreeView and create a new empty one ?
Posted on 2003-12-07 10:09:09 by anon
Invoke SendMessage, hTreeview, TVM_EXPAND, TVE_COLLAPSERESET, hRoot


or

Invoke SendMessage, hTreeview, TVM_DELETEITEM, 0, hRoot
Posted on 2003-12-07 10:15:58 by donkey
Donkey,

I tried your code but it doesn't seem to be helping could it be that I have multiple roots instead of a single one?
Posted on 2003-12-07 13:36:08 by Odyssey
Hi Odyssey,

Multiple roots is perfectly possible. Just use NULL for the TVM_DELETEITEM message instead of hRoot, it will clear the Treeview even if it has multiple roots. You might also try to set hRoot to the TVI_ROOT constant instead.
Posted on 2003-12-07 13:54:45 by donkey
It works but it doesn't seem to delete the items any faster.
Posted on 2003-12-07 14:46:39 by Odyssey
The time it takes is the time it takes. Overlay one Treeview on top of the other and swap places when you want to erase one. Then delete the items in the background treeview in a separate thread while continuing to work in the new treeview.
Posted on 2003-12-07 15:22:40 by donkey
I tried anon's idea and it worked :) I destroyed the control the created it again :)
Posted on 2003-12-07 15:27:30 by Odyssey