Hello everybody,
how can i calculate the height of the wintree before all nodes are expanded?
the problem is that i use the ultratree inside a UltraExplorerBarContainerControl, so before i set the container height i need the height of the treeview.
thank you
It is probably too late for an answer but I came access the same question and solved it by adding the height of all visible nodes in the tree:
private void NavTree_AfterExpand(object sender, NodeEventArgs e) { UltraTree aktUltraTree = (UltraTree)sender; ResizeTree(aktUltraTree); } private void NavTree_AfterCollapse(object sender, NodeEventArgs e) { UltraTree aktUltraTree = (UltraTree)sender; ResizeTree(aktUltraTree); } private void ResizeTree(UltraTree aktUltraTree) { if (aktUltraTree.Tag != null && aktUltraTree.Tag is UltraExplorerBarGroup) { UltraExplorerBarGroup aktUltraExplorerBarGroup = (UltraExplorerBarGroup)aktUltraTree.Tag; int height = CalculateTreeHeight(aktUltraTree); aktUltraExplorerBarGroup.Settings.ContainerHeight = height + 10; } } private int CalculateTreeHeight(UltraTree aktUltraTree) { int retval = 0; AddNodeHeights(aktUltraTree.Nodes, ref retval); return retval; } private void AddNodeHeights(TreeNodesCollection nodes, ref int sum) { if (nodes != null && nodes.Count > 0) { foreach (UltraTreeNode aktUltraTreeNode in nodes) { if (aktUltraTreeNode.Parent == null || aktUltraTreeNode.Parent.Expanded == true) { sum += aktUltraTreeNode.Bounds.Height; AddNodeHeights(aktUltraTreeNode.Nodes, ref sum); } } } }