TreeView performance - OwnerDrawText handler called for ALL nodes

L

Luc Kumps

I populate a TreeView (tv) with 1110 nodes like this:

for (int i = 0; i < 10; i++)
{
tv.Nodes.Add("x"+i.ToString());
for (int j = 0; j < 10; j++)
{
tv.Nodes.Nodes.Add("y"+j.ToString());
for (int k = 0; k < 10; k++)
tv.Nodes.Nodes[j].Nodes.Add("z"+k.ToString());
}
}

It has DrawMode=OwnerDrawText.
Initially, my handler gets called 20 times (twice for each displayed root
node).

Then I execute this line of code (on pressing a Button):

tv.Nodes[0].Text = "hello world";

The handler then gets called for *every* single node in the tree (even
though only 10 nodes are being displayed).
Even with DrawMode=Normal, I see that 1110 WM_USER+7246 messages are being
delivered to the TreeView window, just because the Text property of a single
node was modified!
Is there any way to eliminate the OwnerDraw events for the 1100 nodes NOT
being displayed?
Is there any use for *every* node being redrawn upon modification of a
single node text?
Even with DrawMode=Normal, it takes about 110ms to change the Text of a
single node...

TIA,
Luc K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top