Showing posts with label Winform. Show all posts
Showing posts with label Winform. Show all posts

Friday, March 5, 2010

Updating Text in TreeView Control (Fastest Way)

You might be wondering why i am writing blog for simplest task like Updating a Node text in Treeview Control ( Winform ) ?

Answer is performence !!!!
If you have a TreeView control with thousands or mllions of TreeNode inside and you want to change Text of a specific Node or set of Node then you might notice some performence trouble.( by the way What is the fastest way of finding the node in Tree View ? : Wait for my next blog... ;) ) .

Ok lets come to the point again : When we call function Node.Text TreeView tries to render itself and it takes time. So what is the solution ?

The solution is to calll TreeView.BeginUpdate before updating Text and call TreeView.EndUpdate() after the text change operation.

I have noticed performence increased 20 times with this method.

Thanks and have a good Weekend !