Flexible TreeView Flexible TreeView


Support & Community

Update performance optimization

Previous Table of Contents Next

After changes, treeview will need to recalculate an internal state and redraw itself. All internal changes (add or remove node/node control/column, etc.) will update the treeview automatically, but if you change external data or want to control the update process (on mass or frequently changes) to minimize performance overhead, you will need to update the treeview manually.
Flexible TreeView allows you to do that by using these methods:

  • FullRepaint – completely updates treeview. Use it when you`ve updated data the treeview isn`t familiar with. When executed often, this operation may be a load on your computer`s resources depending on what resources you have available. If you find this to be the case, you may not want to use it often. Use the BeginUpdate and EndUpdate methods for frequently updates instead;
  • BeginUpdate – blocks any treeview updates. Usually used before mass and frequently changes;
  • EndUpdate – unblocks treeview updates after it has been locked by the BeginUpdate method.


Performance improvements hint

In fact, the availability of columns influences the speed of adding and deleting nodes in Flexible TreeView. If there are columns in the tree, when changing node content, it doesn't need to recalculate maximum width of all nodes in order to show a horizontal scroll, meaning that its work is significantly accelerated.
If the treeview contains no columns, with each change the treeview must recalculate maximum  width of all nodes, which can slow work down if there are many nodes.
Therefore, in order to accelerate your work with nodes, you should add at least one column, if possible.


Update after external changes

Treeview will auto–update itself when any data that it is familiar with has changed. To update the treeview after external data changes, call the FullRepaint method. Do not call it too often because it may hurt the treeview performance.

Example:

private void button1_Click(object sender, System.EventArgs e)
{
  NodeWithImage node = (NodeWithImage)tree.Nodes[0];
 
  // external data changes here. Treeview doesn`t know about these changes.
  node.Image.SetResolution(72, 72);
 
  // treeview complete update after changes.
  tree.FullRepaint();
}


Update performance optimization

On mass data changes, like nodes insertion or deletion, every one of these change may cause the treeview to update. To optimize performance, call the BeginUpdate method before and the EndUpdate method after these changes. It will suspend any updates or change notifications between those calls.

Example:

// deny any updates or notifications
tree.BeginUpdate();
 
// do mass changes.
for(int i = 0; i < 1000; i++)
{
  Node node=new Node("Node #"+i);
  node.AttachTo(tree);
}
 
// restore normal update behavior.
tree.EndUpdate();

Note that we didn`t call the FullRepaint method because our changes are "known" changes and treeview will update itself automatically after the EndUpdate method call.
Using this technique, treeview will be updated only once.


Note that you can call the FullRepaint  method between the BeginUpdate/EndUpdate methods as many as you need. This won`t hurt the treeview performance.

 

Previous Top Next


Last news
Bookmark and Share
Use Flexible TreeView in WPF project
Sunday, 18 December 2011

Do you have a WPF project and want to use Flexible TreeView there? No problem!

Flexible TreeView v3.4
Friday, 16 December 2011

Flexible TreeView v3.4 maintenance release has been released.

Flexible TreeView v3.3
Friday, 23 September 2011

Flexible TreeView v3.3 maintenance release has been released. Separate assemblies for .NET 2.0, 4.0 and 4.0 Client Profile, HTML markup extension, etc.

Latest release

Version:
Release date:
3.4
Dec 16, 2011


Copyright © 2006-2012 ARMSoft. All rights reserved.