Hi
I have 2 ultratrees side-by-side with the same number of rows.
How do I keep them in sync?
Hi,
There's no simple way to do this unless you can find the matching node in the other tree. So if your tree's both contain the same nodes with the same keys, then you could trap the events of the first tree like AfterExpand and AfterCollapse. Then you could find the matching node in the other tree and expand/collapse it as appropriate.
For scrolling, you would do the same thing using the Scroll event of the tree and set the FirstNode property of the other tree to the matching node in the current tree.
If the nodes have keys, then finding the node in the other tree is pretty easy, you can use the tree.GetNodeByKey method. If your nodes are not keyed, then you would have to use the node indices and walk down the hierarchy recursively to find the matching node in the other tree.
Under which class is the FirstNode property?
Sorry, it's TopNode, not FirstNode. It's on the tree control itself.
TopNode is working correctly when I use the thumbs on the scrollbars.
But I use the mouse wheel to scroll, then my ultratrees become offset by 1 element. It appears that TopNode is set to the current item and not the new item. I also tried the MouseWheel event but it has the same behavior. Any ideas?
I have been able to do something but I wander if it is "legit"!
When I detect a MouseWheel event, I handle it, set my other tree TopNode and cancelled the Scroll event that occurs right after.
Would there be another (better) way of doing it?
private bool _ignoreNextScroll; void treeHeadersLeft_MouseWheel(object sender, MouseEventArgs e) { bool up = e.Delta > 0; ScrollTree(treeHeadersLeft, treeHeadersRight, up); } void treeHeadersRight_MouseWheel(object sender, MouseEventArgs e) { bool up = e.Delta > 0; ScrollTree(treeHeadersRight,treeHeadersLeft,up); } private void ScrollTree(UltraTree treeActive, UltraTree treePassive, bool up) { _ignoreNextScroll = true; UltraTreeNode topNode = treeActive.TopNode; if (topNode == null) return; UltraTreeNode newTopNode = topNode.NextVisibleNode; newTopNode = up ? topNode.PrevVisibleNode : topNode.NextVisibleNode; if (newTopNode != null) treePassive.TopNode = newTopNode; } void treeHeadersRight_Scroll(object sender, TreeScrollEventArgs e) { if (_ignoreNextScroll) { _ignoreNextScroll = false; return; } treeHeadersLeft.TopNode = treeHeadersRight.TopNode; } void treeHeadersLeft_Scroll(object sender, TreeScrollEventArgs e) { if (_ignoreNextScroll) { _ignoreNextScroll = false; return; } treeHeadersRight.TopNode = treeHeadersLeft.TopNode; }
Hello,
I have opened a private case for you so that I can link it to this development issue. This way you will be notified automatically when the developement issue is updated. The case number is "CAS-130042-X8N2N9". You will see it located here: https://ko.infragistics.com/my-account/support-activity
Let me know if you have any questions regarding this matter.