How can I access the DisplayFormat property?

I can see it only in the object inspector and not by code:

DBGrid1.Columns[0] .displayformat

Doesn't exist.
a.


Jesus Reyes wrote:
--- Andrea Mauri <[EMAIL PROTECTED]> escribió:

Dear all,
I have some problems with TDBgrid and float values.
Firebird database.
I have a table with two fields.
One field is a (FIELD_FLOAT) FLOAT and the other DOUBLE PRECISION (FIELD_DOUBLE).
I tried some inserts and I show the table using DBGrid.
If I exec this:
insert into TABLE1 (FIELD_FLOAT, FIELD_DOUBLE) values (0.15, 9.11)

In the DBgrid I see:
FLOAT field: 0.150000005960464
DOUBLE field: 9.109999999999999

In delphi I see the same as in lazarus for the float field but for
the double I see correctly 9.11

I think that there are some problems with significant digits.
I tried to explore the code of TDBgrid ut I was not able to
understand it. I am a newbie.
Any help, suggestion?
a.


Dbgrid only handles strings, conversion from numeric fields is done
through TField.AsString, so is not surprising that you didn't find
anything in dbgrid.

I think this needs to be checked in fcl-db, but there is an easy
solution, add custom columns to your dbgrid and for the column
holding your float fields set an appropiated DisplayFormat, for
example #,###.00 or something, the format mask string should is
described in formafloat function:
http://freepascal.org/docs-html/rtl/sysutils/formatfloat.html

Jesus Reyes A.

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/
_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


--
Andrea Mauri
PhD student - Chemical Sciences
Milano Chemometrics and QSAR Research Group
Department of Environmental Sciences
University of Milano-Bicocca P.zza della Scienza, 1
20126 Milano - Italy

Tel: ++39 02 64482801
mailto:[EMAIL PROTECTED]
http://www.disat.unimib.it/chm/

Reply via email to