Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Format a DBGrid Column to Display Two Decimal Places? [duplicate]

I would like to format specific cells to force two decimal places. The data is coming from an ElevateDB stored procedure and hooked into a TDataSource.

EDIT: SQL Programming Note:

I wasn't sure if this was just an ElevateDB issue or not. Before knowing about the Fields Editor, I attempted to format the data at the SQL level by using a CAST (NumericField as varchar(10)) statement inside the stored procedure. By doing so, it did not expose the DisplayFormat property inside the fields editor for this particular field.

When I removed the CAST() statement from the stored procedure, the DisplayFormat property showed up in the Fields Editor.

like image 784
Michael Riley - AKA Gunny Avatar asked Apr 22 '12 20:04

Michael Riley - AKA Gunny


1 Answers

You can format the DBGrid columns by formatting the underlying fields. If not done, create static fields in your dataset and then set the DisplayFormat property of the field in question to 0.00 and you are done.

like image 143
Uwe Raabe Avatar answered Sep 19 '22 22:09

Uwe Raabe