Recent

Author Topic: [SOLVED] DBGrid - how to show nice Numeric field from DBF?  (Read 8972 times)

abix_adamj_pl

  • New Member
  • *
  • Posts: 18
[SOLVED] DBGrid - how to show nice Numeric field from DBF?
« on: March 14, 2011, 01:10:30 pm »
I have a TBGrid component, in which I display DBF file. In dbf I have Numeric fields and I would like to show these fields in "normal" way, not engeniering. I attach screens from the application and from dbu utility, which shows real values in these fields.

Can someone give me some hint, how to change type of view in db grid?

Adam
« Last Edit: March 15, 2011, 02:50:07 pm by abix_adamj_pl »

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #2 on: March 14, 2011, 04:39:28 pm »
Look at this patch here ( bug12928.diff )
(TDbf show numbers in scientific notation in TDBGrid)

http://bugs.freepascal.org/view.php?id=12928

Workarround
TFloatField(db.fieldbyname('field')).precision := 15

Regards.
« Last Edit: March 14, 2011, 04:41:48 pm by clauslack »

abix_adamj_pl

  • New Member
  • *
  • Posts: 18
Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #3 on: March 14, 2011, 06:37:02 pm »
TFloatField(db.fieldbyname('Z5')).precision := 15;

produces an error in compiling:

project1.lpr(152,29) Error: Identifier not found "fieldbyname"

Lazarus 0.9.28.2010ubuntu1

Any hint?

Adam

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #4 on: March 15, 2011, 01:28:13 am »
You must replace db with the name of TDbf component, in my case
Dbf1.  (db is the unit db.pas)

EJ
Code: [Select]
Dbf1.open;   
TFloatField(Dbf1.fieldbyname('Z5')).precision := 15; 

But the best option is apply the patch bug12928.diff  to TDbf component and recompile this package.

abix_adamj_pl

  • New Member
  • *
  • Posts: 18
Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #5 on: March 15, 2011, 09:38:05 am »
Great!!!!!! Thank you for help.

Exactly should be:
Code: [Select]
TFloatField(Form1.DBf1.fieldbyname('Z5')).precision := 15; and after that Grid looks like a perfect woman ;-)

Another question is, do you know, in which version of Lazarus patch (bug12928.diff) is applied ?

Adam

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #6 on: March 15, 2011, 02:27:14 pm »
This patch (and others for TDbf)  is not in any version.
Because the developer (Micha Nelissen) is "missing"

The TDbf project seems to be stalled (for 3 years)
Check
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/packages/fcl-db/src/dbase/


Maybe other developer can apply this patch to the the TDbf source.







abix_adamj_pl

  • New Member
  • *
  • Posts: 18
[SOLVED] Re: DBGrid - how to show nice Numeric field from DBF?
« Reply #7 on: March 15, 2011, 02:49:31 pm »
Cool ;-(

So, I just use it in my application and nothing more. Thanks a lot once again for help.

Adam

 

TinyPortal © 2005-2018