views:

2665

answers:

3

I am using a DBGrid component in delphi. I wonder how I can set the format of a column. I have real values that I want to be displayed as currency in the grid.

Someone knows how?

+2  A: 

The first port of call is the DisplayFormat of the data field in the database itself.

mj2008
I've set the column type to decimal(20,2) in my old MySql 4.1 database. Trailing zeros are not shown in the DBGrid. Is there something else to set?
Blue
+4  A: 

(1) You can Set the DisplayFormat of Field.
(2) You can change too, in the OnGetText event. At this you can do more complex operation with the value.

Excuse-me for my bad english.

Neftalí.

Neftalí
Your english is probably as good as mine :-)
Blue
+1  A: 

If you don't add the fields to field Editor list you can get the formating by code as :

TFloatField(MyQuery.fieldByName('MyField').DisplayFormat := '0.00';

if you don't want to show the zeros replace '0.00' with '#.##';

Mohammed Nasman