大家好,又见面了,我是你们的朋友全栈君。
procedure TformBuy.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
var
S: String;
i, x, y, iTextWidth: Integer;
begin
// if Field.DataType <> ftBCD then Exit;
if Field.FieldName <> ‘jxdmoney’ then Exit;
with TDBGrideh(Sender).Canvas do
begin
iTextWidth := TextWidth(‘8’) + 4;
y := Rect.Top + (Rect.Bottom – Rect.Top – TextHeight(‘8’)) div 2;
S := StringReplace(FormatFloat(‘0.00’, Field.AsCurrency), ‘.’, ”, []);
if Field.AsCurrency < 0 then Font.Color := clRed;
FillRect(Rect);
i := (Rect.Right – Rect.Left) div iTextWidth;
repeat
x := Rect.Right – iTextWidth * i;
if i <= Length(S) then
TextOut(x+3, y, S[Length(S)-i+1]);
if i = 2 then
Pen.Color := clRed
else if (i = 0) or ( (i>2) and (((i-2) mod 3) = 0) ) then
Pen.Color := clGreen
else
Pen.Color := clSilver;
MoveTo(x, Rect.Top);
LineTo(x, Rect.Bottom);
Dec(i);
until (i<0)
end;
end;
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/107086.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...