Treeview: Nodes.Clear method slower than removing one-by-one 
Author Message
 Treeview: Nodes.Clear method slower than removing one-by-one

Just discovered this (well I thought it was interesting, anyway..)

clearing all nodes by using tv.Nodes.Clear is about 20 times slower than

For i = tv.Nodes.Count to 1 step -1
tv.Nodes.Remove i
Next

I wonder why... (idle curiosity!)

Jonathan Gibbs



Mon, 15 Dec 2003 06:15:42 GMT  
 Treeview: Nodes.Clear method slower than removing one-by-one
But if you set enable to false prior to the clear, it is{*filter*}ety split.


Quote:
> Just discovered this (well I thought it was interesting, anyway..)

> clearing all nodes by using tv.Nodes.Clear is about 20 times slower than

> For i = tv.Nodes.Count to 1 step -1
> tv.Nodes.Remove i
> Next

> I wonder why... (idle curiosity!)

> Jonathan Gibbs



Wed, 17 Dec 2003 00:22:36 GMT  
 Treeview: Nodes.Clear method slower than removing one-by-one
Hey!  Really useful tip - thankyou!

I do like my splits to be{*filter*}ety.

Jonathan


Quote:
> But if you set enable to false prior to the clear, it is{*filter*}ety split.



> > Just discovered this (well I thought it was interesting, anyway..)

> > clearing all nodes by using tv.Nodes.Clear is about 20 times slower than

> > For i = tv.Nodes.Count to 1 step -1
> > tv.Nodes.Remove i
> > Next

> > I wonder why... (idle curiosity!)

> > Jonathan Gibbs



Wed, 17 Dec 2003 05:43:44 GMT  
 Treeview: Nodes.Clear method slower than removing one-by-one
Thanks.  Helps me too.

If anyone finds a more elegant solution, please post it.  

By the way, I would definately classify this as a bug.

Crazy Tim

Quote:
>-----Original Message-----
>Hey!  Really useful tip - thankyou!

>I do like my splits to be{*filter*}ety.

>Jonathan



>> But if you set enable to false prior to the clear, it
is{*filter*}ety split.


in message

>> > Just discovered this (well I thought it was

interesting, anyway..)
Quote:

>> > clearing all nodes by using tv.Nodes.Clear is about

20 times slower than

- Show quoted text -

Quote:

>> > For i = tv.Nodes.Count to 1 step -1
>> > tv.Nodes.Remove i
>> > Next

>> > I wonder why... (idle curiosity!)

>> > Jonathan Gibbs

>.



Wed, 31 Dec 2003 00:49:57 GMT  
 Treeview: Nodes.Clear method slower than removing one-by-one
This one has always kept me fairly happy:

  With TreeView1.Nodes
    ' the loop is for multiple Root Nodes...
    Do While .Count
      Call .Remove(.Item(1).Root.Index)
    Loop
  End With

Among other things, the reason this is much faster is that if the
Node being Remove'd has descendent Nodes, before processing
the TVM_DELETEITEM message, the real treeview (that the VB
TreeView superclasses) first collapses the Node, removes all of
its descendent Nodes, and finally the Node itself, eliminating
potentially many unnecessary and time consuming tree redraws...

--
Brad Martinez, http://www.*-*-*.com/
Please direct questions/replies to the newsgroup

Quote:

>Thanks.  Helps me too.

>If anyone finds a more elegant solution, please post it.

>By the way, I would definately classify this as a bug.

>Crazy Tim

>>-----Original Message-----
>>Hey!  Really useful tip - thankyou!

>>I do like my splits to be{*filter*}ety.

>>Jonathan



>>> But if you set enable to false prior to the clear, it
>is{*filter*}ety split.


>in message

>>> > Just discovered this (well I thought it was
>interesting, anyway..)

>>> > clearing all nodes by using tv.Nodes.Clear is about
>20 times slower than

>>> > For i = tv.Nodes.Count to 1 step -1
>>> > tv.Nodes.Remove i
>>> > Next

>>> > I wonder why... (idle curiosity!)

>>> > Jonathan Gibbs

>>.



Wed, 31 Dec 2003 14:16:14 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. BUG:Treeview.Nodes.Clear method very slow with ComCtl32.DLL version 4.71.17123

2. TreeView-Removing Checkbox From One Node Level

3. treeview.nodes.clear slow!?

4. Treeview nodes clear slow ..The Fix!

5. TreeView nodes clear method

6. TreeView nodes clear method - SOLUTION

7. Focus on the Tree.Nodes.Clear method in treeview control

8. Slow TreeView Clear Method

9. Slow TreeView Clear Method?

10. Treeview: focus on one node

11. Slow updates in Treeview on all machines except the one used in development

12. TreeView - HowTo step one by one?

 

 
Powered by phpBB® Forum Software