Hi,
I have tree with thousands of nodes (up to 2 000). Loading is quite fast thanks to AddRange method in Nodes property. Now I have a task to set many of the nodes (or each of them) to Selected = true. There is very bad performance with that.
Code looks like that:
foreach( UltraTreeNode childNode in Nodes)
{
if( someCondition)
childNode.Selected = true;
}
Profiler says, that most of the time is spent in node.Selected = true (more specifically SelectedNodesCollection.InternalAdd and finaly ArrayList.Contains - this is the problem). I was trying to find something like SelectedNodes.AddRange method or something like that but with no success. What can I do to speed up nodes selection ? Thanks for any advice.
Daniel
Hi Daniel,
The performance problem is most likely caused by the contanst painting of the control. Try this:
tree.BeginUpdate();
try
finally
tree.EndUpdate();
I've already tried this..still very slow, because problem is not with constant redraw, but with slow ArrayList.Contains method. I'm using 2008 vol.1 version of Infragistics WinForms, I have vol.2 . We are going to use new version in a few weeks, but I'm not sure it helps. Got some other tips ? Thanks
Theming has no bearing on selection. The issue is that setting the Selected property of UltraTreeNode causes a property change notification, which in turn causes metrics recalculations, repainting, etc. This issue will be addressed in a future release; in the meantime, the following workaround demonstrates how to use the ISelectionManager interface to select a range of nodes as one atomic operation:
private void SelectRange( UltraTree tree, UltraTreeNode start, UltraTreeNode end ){ ISelectionManager selectionManager = tree as ISelectionManager; selectionManager.ActivateItem( start ); selectionManager.SelectItem( start, false ); selectionManager.SetPivotItem( start, false ); selectionManager.SelectRange( end, false );}
This might be worth a try. Set UseOsThemes = False. Paint performance slows to a crawl if this is true and you are using app styling.
Hm, I don't think v8.2 will help any. I recommend that you Submit an incident to Infragistics Developer Support and report this as a bug. It seems to me that the code here could be made more efficient or n AddRange method could be added.