Changing Font

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Changing Font

Post by McMClark » Thu Dec 14, 2006 8:44 pm

I am using Delphi 2006 BDS. I am populating a DBTree at runtime. My code is below. How do I change the font for the labels of the nodes and shapes?

ModelTree_Query1.Close;
ModelTree_Query1.Database := frmSearch.Extractor_Database1;
ModelTree_Query1.SQL.Clear;
ModelTree_Query1.SQL.Add('Select A.ModelName,A.ModelID,B.SubModelName, B.SubModelID, C.Subject, C.SubjectID, ');
ModelTree_Query1.SQL.Add(' D.Element, D.ElementID From Models as A, ProfileSubmodel as B, ProfileSubModelSubject as C, ');
ModelTree_Query1.SQL.Add(' ProfileSubjectElement as D Where A.ModelID = B.ModelID and B.SubModelID = C.SubModelID and ');
ModelTree_Query1.SQL.Add(' C.SubjectID = D.SubjectID and A.ModelID=:intModelID;');
ModelTree_Query1.ParamByName('intModelID').asInteger := intModelID;
ModelTree_Query1.ActiveRuntime := True;

DBTree1.Layout.Clear;
with DBTree1.Layout.Add do
begin
DataSet := ModelTree_Query1;
CodeField := '' ;
ParentField := 'ModelName;SubModelName;Subject;Element';
Fields := 'ElementID';
end;
DBTree1.MultiLineText := True;
DBTree1.Refresh;
DBTree1.Roots[0].Expanded := True;

Thanks

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

Post by tom » Sat Dec 16, 2006 6:15 pm

Hi,

There are several ways:

0) Using the GlobalFormat to change the default used format for a node:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  DBTree1.GlobalFormat.Font.Color := clGreen;
  DBTree1.GlobalFormat.Font.Size := 8;
end;
1) Using the HeaderFormat and/or Format property of the Layout class:

Code: Select all

with DBTree1.Layout.Add do
begin
       DataSet := ModelTree_Query1;
       CodeField := '' ;
       ParentField := 'ModelName;SubModelName;Subject;Element';
       Fields := 'ElementID';
       HeaderFormat.Text.Add('Model');
       HeaderFormat.HorizTextAlign := htaLeft;
       HeaderFormat.Border.Visible := True;
       Format.HorizTextAlign := htaLeft;
       Format.Border.Visible := True;
       Format.Font.Color := clYellow;
end; 
Regards,
Tom.

Post Reply