procedure TSJWG1.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);
var
S: String;
i, x, y, iTextWidth: Integer;
begin
if AColumn.Name<>'DataGridJE' then Exit;
with ACanvas do begin
iTextWidth := TextWidth('8') + 4;
y := ARect.Top + (ARect.Bottom - ARect.Top - TextHeight('8')) div 2;
S := Business.System.SysUtils.StringReplace(sysutils.FormatFloat('0.00',DataSetBrokerBZSJJ1.DataSet.FieldByName('je').AsFloat), '.', '', []);
if DataSetBrokerBZSJJ1.DataSet.FieldByName('je').AsFloat < 0 then Font.Color := Business.System.Graphics.clRed;
if ASelected then Font.Color := Business.System.Graphics.clBlack;
FillRect(ARect);
i := (ARect.Right - ARect.Left) div iTextWidth;
repeat
x := ARect.Right - iTextWidth * i;
if i <= Length(S) then
TextOut(x+3, y, s.Chars[s.Length-i]); //S[Length(S)-i+1]
if i = 2 then
Pen.Color := Business.System.Graphics.clRed
else if (i = 0) or ( (i>2) and (((i-2) mod 3) = 0) ) then
Pen.Color := Business.System.Graphics.clGreen
else
Pen.Color := Business.System.Graphics.clSilver;
MoveTo(x, ARect.Top);
LineTo(x, ARect.Bottom);
Dec(i);
until (i<0);
ADone := true;
end;
end; |