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?
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.
I tried this out and I am seeing similar results, although it's not always just the mouse wheel. If I click and drag the thumb, the tree doesn't seem to fire the Scroll event to reflect the current TopNode until I release the mouse sometimes.It's not always consistent.
This appears to be a bug in the tree.So I'm going to ask Infragistics Developer Support to create a case for you and write this up as a bug for developer review.
Your workaround seems okay, except that you are not honoring the delta. For example, if Delta is 3, you are only going to scroll one node at a time. Also... since you are not cancelling the MouseWheel event, I would think that this code would cause the tree to scroll double - once because you are telling it to and again because of the built-in handling of the mouse wheel.
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; }
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?
Sorry, it's TopNode, not FirstNode. It's on the tree control itself.