View Full Version : How to set the number of decimals in DBGrid?
Hi everyone;
I want to set the number of decimals in DBGrid like x.xxx.
I know about DisplayFormat, but how to use it ?
Thanks, Alex
Hi,
Try this one:
on the data module - or where the TTable component placed on - double click the TTable component of the DBGrid's Dataset. By right click You can modify the field list that you can use in the application. If You chose a numeric field from these and press F11, you will see the properties for the current field. You can set up the display format for this field the Display Format property field like this:
###,###.00
(additional help in Delphi Help/Index/DisplayFormat,TNumericField
I hope this will help You
Regards,
MZperX
I've got the same problem. DisplayFormat is fine at design time, but how about run time?
Query1.Fields[i].DisplayFormat := '###,###.00';
doesn't work.
Bob.
Found the answer - I needed to cast to TNumericField.
if Query1.Fields[i].DataType = ftFloat then
TNumericField (Query1.Fields[i]).DisplayFormat
:= '###,###.00';
Bob.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.