Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Temporarily disable UltraTree sorting while creating nodes?
posted

Is there a way to temporarily disable tree column sorting?

My program is manually building a node hierarchy (not using data binding).  I also have a custom IComparer implementation assigned to a column that is sorting by default.  It seems that the sort is refreshed after every node added, causing the process of adding approx. 640 nodes to take a significant amount of time (5-10 seconds) and CPU utilization.  After setting all columns to not sort, adding the same number of nodes is practically instantaneous.

I dug around the docs looking for properties/methods that would disable sorting, but the closest thing I found was the "AllowSorting" property available in various parts of the tree instance, and setting that to false didn't help.  Am I missing it?

I wrote a small class in the meantime to save, clear, and restore an UltraTree's sort settings.  I'll attach it in case anyone else needs it, feel free to use/improve.

Thanks,

Jim

  • 69832
    Offline posted

    You can set the SortComparer property to null prior to populating, then re-assign it after the Nodes collections are populated. Alternatively, you can use the Nodes collection's AddRange method to populate instead of the Add method, so the collection only gets sorted once.