Forum
× General Forum discussions that don't fit in any of the other specific forum categories, help etc.

Question Using DisplayFormat in DBGrid

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 weeks 4 days ago #13186 by universe
Using DisplayFormat in DBGrid was created by universe
Hello all,
I am using the DisplayFormat property in DBGrid for a float field with spaces (### ##0.###).
The values are displayed correctly but when I try to edit for example changing 1 200 to 1 255 I receive the error "1 255" is not a valid float.
PS: The value is accepted only after deleting the whole thing and giving a new value. The error is raised in TCustomDBGrid.UpdateData. located DBGrids.pas.
I found a workaround, is this the correct way or I am misusing DisplayFormat ?
So I changed
edField.Text := FTempText
To
if edField.DataType in [ftFloat,ftCurrency] then
   edField.Text := FTempText.Replace(' ','')
else
   edField.Text := FTempText; 

Please Log in or Create an account to join the conversation.

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 weeks 4 days ago #13187 by universe
Replied by universe on topic Using DisplayFormat in DBGrid
No suggestions?

Please Log in or Create an account to join the conversation.

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
3 weeks 2 days ago - 3 weeks 2 days ago #13189 by universe
Replied by universe on topic Using DisplayFormat in DBGrid
I am experiencing a strange behavior with DisplayFormat, for example if I set DisplayFormat to ### ##0.### in both DBGRID and DBEdit and I enter these numbers
For example:
  1 234.567    will be    1 234.56 
 12 345.678    will be   12 345.6
123 456.789    will be  123 456

The more digits added the less decimals are shown, if I remove the display format the default representation is a scientific one and I want to avoid it.
PS: I tested it for the format without spaces #####0.### too and gives the save result.
Last edit: 3 weeks 2 days ago by universe.

Please Log in or Create an account to join the conversation.