Hiding root nodes

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Phineas
Newbie
Newbie
Posts: 18
Joined: Wed Apr 09, 2008 12:00 am

Hiding root nodes

Post by Phineas » Sun Jun 08, 2008 11:24 pm

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

Ashu
Newbie
Newbie
Posts: 24
Joined: Mon Mar 08, 2004 5:00 am

Post by Ashu » Mon Jun 09, 2008 7:14 am

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

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Tue Jun 10, 2008 9:45 pm

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

Post Reply