It's really a bad idea to format your results inside the query. The query should be used to retrieve information... presentation should be handled elsewhere. In this case, I would use (I do use, in fact) the DisplayFormat, as suggested in comments.
You can also write some code to format automatically, if you don't always want to add the fields to the TDataSet on design-time:
DataSet.Open;
For I := 0 To DataSet.Fields.Count - 1 Do Begin
If DataSet.Fields[I] Is TFloatField Then
(DataSet.Fields[I] As TNumericField).DisplayFormat := '###,###,##0.00'
Else If DataSet.Fields[I] Is TIntegerField Then
(DataSet.Fields[I] As TNumericField).DisplayFormat := '###,###,##0';
End;
This should be adapted to your actual needs... you could read metadata from BD (this is BD-dependent) to decide on precision, for example.
Inside FastReport, you could also use DisplayFormat, or you can also use the format function inside your memo: [Format('%.2n', [<DataSet."Field">])]
, where the .2
indicates the precision to be used.
EDIT: To address the problem of the minus sign appearing on the right with BiDiMode = bdRightToLeft
(See this), I believe you'll really need to use OnGetText
event. I think you already found this workaround yourself, but I'm including it nevertheless for completeness:
procedure TForm1.FieldGetText(Sender: TField; var Text: String; DisplayText: Boolean);
var
FmtStr: string;
F: Double;
begin
F := Sender.AsFloat;
FmtStr := TNumericField(Sender).DisplayFormat;
if Sign(F) = -1 then
Text := '-' + FormatFloat(FmtStr, Abs(F))
else
Text := FormatFloat(FmtStr, F)
end;