Setting a DBGrid column format in Delphi
- You can set the
DisplayFormat
of theField
- You can handle
OnGetText
event. This approach allows to do more complex operations with the value.
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 '#.##';
The first port of call is the DisplayFormat of the data field in the database itself.