Reputation: 617
I'm working with WinForms in .NET 2010. I've created a user control that inherits from Treeview and I'm using owner-drawing for the text part of my treenodes.
Now I had to solve a strange performance problem:
When the text of a treenode (I call it "parentnode") gets changed, the treeview control fires the DrawNode-event for each of "parentnodes"'s child nodes, whether they are visible or not!!!
This is causing a big performance problem for my application. How can I prevent the treeview control from firing the DrawNode event for each child node?
Thx a lot in advance for you help!
Upvotes: 3
Views: 347
Reputation: 941347
I don't get a stellar repro for this, it does only generate DrawNode events for visible nodes. However, I do see it generate DrawNode events for child nodes whose parent is collapsed. You can filter those like this:
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e) {
if (e.Bounds.Height == 0) return;
// etc..
}
Upvotes: 2