用数值型字段的displayformat属性:###.##

解决方案 »

  1.   

    该字段的OnGetText事件中:
    if Sender.AsCurrency=0 then
      Text :=' '
    else
      Text :=Fomatfloat('#,##0.00',Sender.AsCurrency) ;
      

  2.   

    写DBGrid的OnDrawColumnCell事件:
    procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    begin
         if Column.FieldName='YourFieldName' then
         begin
              if Column.Field.AsInteger<>0 then
              begin
                   DBGrid1.Canvas.TextRect(Rect,Rect.left+2,Rect.Top+2,Column.Field.AsString);
              end
              else
              begin
                   DBGrid1.Canvas.TextRect(Rect,Rect.left+2,Rect.Top+2,'');
              end;
         end;
    end;