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
Changing Font
Hi,
There are several ways:
0) Using the GlobalFormat to change the default used format for a node:
1) Using the HeaderFormat and/or Format property of the Layout class:
Regards,
Tom.
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;
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;
Tom.