Make node visible in TTree

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Lenfors
Newbie
Newbie
Posts: 49
Joined: Thu Sep 20, 2007 12:00 am

Make node visible in TTree

Post by Lenfors » Mon Oct 21, 2013 2:23 pm

Hello!

I have a TTree with a lot of nodes in it. How can I programatically make a certain node to be visible in the Tree? (Inside the visible area of the tree)

Best regards, Mikael

Yeray
Site Admin
Site Admin
Posts: 9509
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Make node visible in TTree

Post by Yeray » Wed Oct 23, 2013 3:05 pm

Hi Mikael,

Can't you do this with a TTreeNodeShape?

Code: Select all

TreeNodeShape1.Visible:=true;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Lenfors
Newbie
Newbie
Posts: 11
Joined: Mon Oct 07, 2013 12:00 am

Re: Make node visible in TTree

Post by Lenfors » Wed Oct 23, 2013 7:12 pm

Sorry, I explained badly... In my TTree I have a tree structure displayed, like in Explorer. Now I want my TTree to scrool so that my current node becomes visible.

best regards, Mikael

Yeray
Site Admin
Site Admin
Posts: 9509
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Make node visible in TTree

Post by Yeray » Fri Oct 25, 2013 1:33 pm

Hi Mikael,

In the following example, we have a root node with a hundred childs.
If you want you can scroll down dragging the Tree with the right mouse button, or you can use the scrollbar for the same.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    TreeNodeShape1: TTreeNodeShape;
begin
  TreeNodeShape1:=Tree1.AddRoot('Root');
  TreeNodeShape1.Expanded:=true;

  for i:=0 to 100 do
    TreeNodeShape1.AddChild('Child ' + IntToStr(TreeNodeShape1.Children.Count+1));
end;
If you are looking for a function to force the scroll to a determined child by code, you can use View3DOptions.VertOffset:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    TreeNodeShape1: TTreeNodeShape;
begin
  TreeNodeShape1:=Tree1.AddRoot('Root');
  TreeNodeShape1.Expanded:=true;

  for i:=0 to 100 do
    TreeNodeShape1.AddChild('Child ' + IntToStr(TreeNodeShape1.Children.Count+1));

  TreeNodeShape1.Children[49].Selected:=true;

  Tree1.Draw;
  Tree1.View3DOptions.VertOffset:=-TreeNodeShape1.Children[49].Y0;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply