StringGrid Header 高度设定方法:
uses FMX.Header; procedure TForm1.StringGrid1ApplyStyleLookup(Sender: TObject);
var Obj: TFmxObject;
begin
// by Aone
Obj := StringGrid1.FindStyleResource('header');
if (Obj <> nil) and (Obj is THeader) then
THeader(Obj).Size.Height := ; // 设定高度
end;
ps. 所有的 Style 都能用这个方法,找到后,再修改它。
StringGrid Header 文字颜色设定方法(不改变底色):
procedure TForm1.StringGrid1DrawColumnHeader(Sender: TObject;
const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF);
var Str: String;
begin
if Column = StringColumn1 then
begin
Str := '表头1';
Canvas.Fill.Color := claBlue;
end;
if Column = StringColumn2 then
begin
Str := '表头2';
Canvas.Fill.Color := claRed;
end; Canvas.FillText(Bounds, Str, False, , [], TTextAlign.Center, TTextAlign.Center);
end;
效果:
StringGrid Header 文字颜色设定方法(改变底色):
procedure TForm1.StringGrid1DrawColumnHeader(Sender: TObject;
const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF);
var Str: String;
BackColor, FontColor: TAlphaColor;
begin
if Column = StringColumn1 then
begin
Str := '表头1';
BackColor := claYellow;
FontColor := claBlue;
end;
if Column = StringColumn2 then
begin
Str := '表头2';
BackColor := claGold;
FontColor := claRed;
end; Canvas.Fill.Color := BackColor;
Canvas.FillRect(Bounds, , , [], );
Canvas.Fill.Color := FontColor;
Canvas.FillText(Bounds, Str, False, , [], TTextAlign.Center, TTextAlign.Center);
end;
效果: