Windows Develop Bookmark and Share   
 index > Windows Forms General > Adding nodes in AfterLabelEdit event handler of treeview control
 

Adding nodes in AfterLabelEdit event handler of treeview control

Hi!

In my windows application I need to add some nodes to a node of a treeview, which number depends on what user enters in the node label. For example: if user edits the label of a node and digits "1-1000", I have to add 1000 nodes to the parent nodes.To do this, Iread the label, calculate the number of nodes and then add them to the parent node. This is a part of code:

e.Node.TreeView.BeginUpdate();

for (int i = 0; i < 3000; i++)

e.Node.Nodes.Add(i.ToString());

e.Node.TreeView.EndUpdate();

The treeview repaintingwas very slow, so I have tried to do the same thing, but out of AfterLabelEdit event handler (I created the nodes after a DoubleClick over a node). The result is thattreeview repaintingis more fast. Why?

Emidio Croci  Monday, December 04, 2006 9:58 AM
This is a fairly typical problem with Windows controls. The event gets fired *before* the control has updated its internal state that label editing is no longer active. If you look close, you'll see the blue highlight moving to each added node and the last added node is in edit mode once you're done. That takes time. To avoid that, you'll need to postpone adding nodes until the control has completely processed the editing operation. That's not that easy to do cleanly, you'll need a node reference field and a timer that you set/enable in the AfterLabelEdit event.
nobugz  Monday, December 04, 2006 7:04 PM
This is a fairly typical problem with Windows controls. The event gets fired *before* the control has updated its internal state that label editing is no longer active. If you look close, you'll see the blue highlight moving to each added node and the last added node is in edit mode once you're done. That takes time. To avoid that, you'll need to postpone adding nodes until the control has completely processed the editing operation. That's not that easy to do cleanly, you'll need a node reference field and a timer that you set/enable in the AfterLabelEdit event.
nobugz  Monday, December 04, 2006 7:04 PM

You can use google to search for other answers

Custom Search

More Threads

• datagrid stubbornly displays wrong popup menu
• passing information
• PageSetup Dialog Customization
• converting image in a clipboard to memory stream
• Need help.
• Viewoptions for WebBrowser as DirectoryBrowser
• richTextbox - Highlight complete line
• Problem in Seeking in Windows Media Player Control
• Split Container
• Updating a ListView dynamically... How?