zoukankan      html  css  js  c++  java
  • 画DBGRID,DBGRIDEH中文帐簿金额栏

    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;

  • 相关阅读:
    gitlab 安装升级
    fping 命令
    sed 命令
    rm 命令
    sort 命令
    第十六单元
    第十五单元
    第十三单元
    第十二单元
    第十一单元
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940745.html
Copyright © 2011-2022 走看看