Welcome, Guest
Username: Password: Remember me
Components and Libraries for Database Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Using DisplayFormat in DBGrid 5 years 8 months ago #13186

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 122
  • Thank you received: 8
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.

Using DisplayFormat in DBGrid 5 years 8 months ago #13187

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 122
  • Thank you received: 8
No suggestions?

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

Using DisplayFormat in DBGrid 5 years 8 months ago #13189

  • universe
  • universe's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 122
  • Thank you received: 8
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.

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

Last edit: by universe.
  • Page:
  • 1