Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CURRENCY IN DBGRID COLUMN

Status
Not open for further replies.

hbez

Instructor
Mar 25, 2003
49
ZA
Will appreciate advice on the following:
I populate a DBGrid from an ADODataSet and DataSource. The Access db has a Currency field. How does one display currency, including two decimals and trailing zeros, in the associated DBGrid column? The DisplayFormat option for the column has no effect, and neither does something like
dbgrTransaction.Columns.Items[4].DisplayFormat := '0.00';
Values are displayed without trailing zeroes.

Many thanks
Hannes
 
something like this should work:

tfloatfield(dbgrTransaction.datasource.dataset.fieldbyname('TheNameOfTheField')).Displayformat := '#,##0.00';

one tip:

the standard VCL DBGrid is limited in many ways.
if you have the cash, go buy the Quantumgrid from devexpress. Once you used this one, you'll never look back again at that stupid DbGrid...

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Many thanks!! I just had to change the mask to #####0.00 and it worked fine. I actually use DBGridEh from ehlib, a fabulous grid that allows all sorts of useful things, including column sums, averages, printing, etc. I will check out how it compares with the one you suggest.
Hannes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top