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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting cells in TStringGrid to currency

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
US
I know this must be incredibly easy but I'm just having a hard time with this.

I'm trying to format a certain column to display currency values. I'm converting the stringGrid cell value to currency and then back to string but I get floating point error. There must be a better way. Can someone help me on this?

Thanks,
Rewdee
 
You can use FormatFloat('$0.00',number) to format and round your number. You'd still be converting to a float and back though. Are you getting a floating point error or an EConvertError? Or just an E+xxx string instead of a number?
TealWren
 
It may be that you are not removing the currency symbol (I've made that mistake). It's now getting rather long-winded using something like
StrToFloat(Copy(Grid.Cells[1,1],2,9))
but the speed of Delphi is such that you can often get away with it.

Does anyone know why doing 2 Canvas.TextRect calls within a string grid OnDrawCell does not work properly? I am getting overwriting in a most peculiar manner even when the 2 TextRects work happily on their own?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top