Page 1 of 1

Hiding root nodes

Posted: Sun Jun 08, 2008 11:24 pm
by 10548832
Hi, Is it possible to hide the root node, and all branch nodes of that root?

Plus, when hidden, the tree closes up as though the hidden root node was not present.

As it is now, I can hide individual nodes but their empty space is still present.

Thanx

Posted: Mon Jun 09, 2008 7:14 am
by 9336073
I am also facign the same problem.

When any node is made hidden in the tree,
The tree should automatically adjust it self as there was no node at that position.

Steema, Please suggest a solution for this.

Regards,
Ashu

Posted: Tue Jun 10, 2008 9:45 pm
by Tom
Hi,

TeeTree was developed not only as a Tree substitute, therefor it doesn't always behaves as a Tree would.

To make all child nodes invisible, you can recursively iterate all childs by yourself, e.g.:

Code: Select all

procedure TForm2.HideClick(Sender: TObject);

  procedure Hide(Node: TTreeNodeShape; Recursive: Boolean);
  var t : Integer;
  begin
    Node.Visible :=False;
    if Recursive then
      for t:=0 to Node.Children.Count-1 do Hide(Node.Children[t], True);
  end;

begin
  Hide(TreeNodeShape1, True);
end;


In order to have another behavior of the X/YPosition of the nodes, you can make a ChildManager descendant which does take the visibility of a node into account. Have a look at the default ChildManager (TTreeExplorerAlignChild) and particulary in the X and YPosition methods. If you then change the default ChildManager to the new developed, the tree will behave as you would like.

Regards,
Tom