Avatar of DigitalNam
DigitalNam
Flag for Namibia asked on

DBGrid column format currency

Hi all,

I have tried everything and searched everywhere but I must be overlooking something. I have a DBgrid that is linked to a query. One of the columns needs to show currency and the field is float. I am using Delphi XE.

I have tried the following but Delphi XE doesn't have the displayformat property.


dbgrid1.colums[NumberOfColum].field.displaymask := '#,##0.00';

//variante 1
procedure TForm1.Button1Click(Sender: TObject);
begin
  TNumericField(dbgrid1.Columns[0].Field).DisplayFormat := '#,##0.00';
end;

//variante 2
procedure TForm1.Button2Click(Sender: TObject);
begin
  TNumericField(dbgrid1.DataSource.Dataset.FieldbyName('FloatFieldName')).DisplayFormat := '#,##0.00';
end;

Open in new window

Delphi

Avatar of undefined
Last Comment
DigitalNam

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Thommy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Emmanuel PASQUIER

I would say the 2nd variant is correct
But why don't you set it at design time on your field object ?
I have checked, Delphi XE has everything in place
DigitalNam

ASKER
Thank you, my problem was that DB.pas not in my uses.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes