We help IT Professionals succeed at work.

DBGrid column format currency

DigitalNam
DigitalNam asked
on
4,451 Views
Last Modified: 2012-05-11
Hi all,

I have tried everything and searched everywhere but I must be overlooking something. I have a DBgrid that is linked to a query. One of the columns needs to show currency and the field is float. I am using Delphi XE.

I have tried the following but Delphi XE doesn't have the displayformat property.


dbgrid1.colums[NumberOfColum].field.displaymask := '#,##0.00';

//variante 1
procedure TForm1.Button1Click(Sender: TObject);
begin
  TNumericField(dbgrid1.Columns[0].Field).DisplayFormat := '#,##0.00';
end;

//variante 2
procedure TForm1.Button2Click(Sender: TObject);
begin
  TNumericField(dbgrid1.DataSource.Dataset.FieldbyName('FloatFieldName')).DisplayFormat := '#,##0.00';
end;

Open in new window

Comment
Watch Question

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Emmanuel PASQUIERFreelance Project Manager
CERTIFIED EXPERT
Top Expert 2010

Commented:
I would say the 2nd variant is correct
But why don't you set it at design time on your field object ?
I have checked, Delphi XE has everything in place

Author

Commented:
Thank you, my problem was that DB.pas not in my uses.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.