1

I have a TreeView which holds approximately 100,000 TreeNodes or even more, I have optimized everything related to loading or unloading them on deserialization process but now I'm stuck with an issue I can't overcome.

Its important to mention I decided not to use the LabelEdit default event given by the control since its pretty tricky to make it work as I wanted to, Its widely known that there are a lot of "problems" with this particular event which have pushed many devs to implement their own custom TreeViews.

In my case I am using a ContextMenu which has a Rename option, this brings a textbox right in front of the TreeNode and then I just simply change the TreeNode.Text property to whatever the user input was in the TextBox keydown event, once we trigger this event, the whole GUI freezes for a couple of seconds (4-5), I'm not doing any Depth search over the TreeNodeCollection or anything, I am directly accessing the TreeNode and modifying the property...

So, any thoughts on what could be wrong here? I already tried BeginUpdate / SuspendLayout / or even a custom solution found here How do I suspend painting for a control and its children? and nothing seems to help.

Community
  • 1
  • 1

1 Answers1

0

The first thing that comes to mind is that when the text is changed on the node, it must be redrawing the entire treeview.

In this situation, suspendlayout will not help, as the control isn't laying its contents.

I think beginupdate stops the drawing when nodes are being added to the list, but the text changed might bypass this.

Have you considered not using the keydown, and just updating the text once the user has dismissed the textbox? (i.e. done editing). Not ideal, but will limit the performance hit to once, instead of every key stroke?

Andrew
  • 144
  • 2
  • 4
  • I'm not triggering the edit process each key stroke (That'd be sick), it's done when the enter key is pressed (Only once), so yeah, need to find a way to not redraw the whole tree and just some particular region, not sure if its possible. –  Apr 17 '14 at 15:47