procedure TGJNRGBYS.DataGridCustomDrawCell(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TTreeListNode; AColumn: TTreeListColumn; ASelected,
AFocused, ANewItemRow: Boolean; var AText: string; var AColor: Integer;
AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean);
begin
{ 如果是当前行,使用系统默认的反白显示 }
if not (ASelected or AFocused) then
begin
{ 分组颜色,根据ANode的HasChildren属性判断 }
if ANode.HasChildren then
begin
AColor := $0F0A0F0;
Exit;
end;
if (ANode.Index mod 2) = 1 then
begin
{ 奇数行颜色 }
AColor := $0F0F0F0;
end;
//根据 XSSL 的值,决定SL这列的颜色
if TDataGridColumn(AColumn).FieldName= 'SL' then
begin
if TDataGridColumn(AColumn).ColumnDef.Field.DataSet.
FieldByName('XSSL').AsInteger >= 100 then
begin
AFont.Color := Business.System.Graphics.clWhite;
AColor := $0F0D0F0;
end else
AFont.Color := Business.System.Graphics.clGreen;
end;
end;
end;
if not (ASelected or AFocused) then // 如果是当前行,则默认系统的反白显示
begin
if ANode.HasChildren then
begin
AColor := $0C9FAFA; // 分组颜色
Exit;
end;
if (ANode.Index mod 2) = 1 then
begin
AColor := $0F0F0F0; // 奇数行颜色
end;
end;