Page 1 of 1

Changing Font

Posted: Thu Dec 14, 2006 8:44 pm
by 9337074
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

Posted: Sat Dec 16, 2006 6:15 pm
by Tom
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.