Listbox as node in teetree

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Maelstromware
Newbie
Newbie
Posts: 3
Joined: Sun Mar 09, 2003 5:00 am
Contact:

Listbox as node in teetree

Post by Maelstromware » Sun May 14, 2006 1:36 pm

Hi

I've been thinking that it would be a very useful feature if one could "embed" or add the functionality of common visual components as nodes in a teetree. For example, is there a way of adding a drop-down listbox as a node to a teetree? Something like a drop-down lookup list in a DBGrid.

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

Post by tom » Mon May 15, 2006 4:31 pm

Hi,

You can handle this in the AfterDraw event, eg:

Code: Select all

{ Draw a control at a node position... }
Procedure DrawControl(AControl:TControl; AShape:TTreeNodeShape);
var P:TPoint;
begin
  AControl.Visible:=AShape.Visible;
  if AControl.Visible then
  begin
    With AShape do P:=Tree.Canvas.Calculate3DPosition(X0,Y0,0);
    AControl.Left:=P.x;
    AControl.Top:=P.y;
  end;
end;

procedure TFormControls.Tree1AfterDraw(Sender: TObject);
begin
  DrawControl(Button1,TreeShape26);
  DrawControl(Edit1,TreeShape27);
  DrawControl(ComboBox1,TreeShape23);
  DrawControl(ListBox1,TreeShape16);
  DrawControl(RadioGroup1,TreeShape15);
  DrawControl(StringGrid1,TreeShape24);
end;

Another way might be to create your own shape descendants.

Kind regards,
tom

Maelstromware
Newbie
Newbie
Posts: 3
Joined: Sun Mar 09, 2003 5:00 am
Contact:

Super help!

Post by Maelstromware » Tue May 16, 2006 7:41 pm

Thank you very much, Tom :). Works beautifully.

Post Reply