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.



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
Flexible TreeView v2.7
Sunday, 01 August 2010

Flexible TreeView v2.7 has been released with completely reimplemented data binding support.

Flexible TreeView v2.6
Thursday, 13 May 2010
Flexible TreeView v2.6 has been released with Visual Studio 2010 support, new NodeDateTime node control, data access great speed increase and much more.
Flexible TreeView v2.5
Saturday, 13 March 2010

Flexible TreeView v2.5 has been released with the new NodeProgressBar node control.

Latest release

Version:
Release date:
2.7.1
Aug 11, 2010


Copyright © 2006-2010 ARMSoft. All rights reserved.