6

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?

4

3 回答 3

9
  1. You can set the DisplayFormat of the Field
  2. You can handle OnGetText event. This approach allows to do more complex operations with the value.
于 2008-10-16T14:41:30.743 回答
5

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 '#.##';

于 2008-10-16T21:36:27.397 回答
2

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

于 2008-10-16T14:08:00.127 回答