Accessing Field DisplayFormat at runtime

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Guest

Accessing Field DisplayFormat at runtime

Post by Guest » Wed 22 Dec 2004 15:00

Hi,
I'm trying to set a DisplayFormat to a Field at run time.
It's through an TMyQuery component. Just like for a TMyTable,
when you right-click on a TmyTable, you can access the fields
available and then set a DisplayMask for each of the present
fields.

How can I do this programatically?

I tried (C++)
qryGeneric->Fields->Fields[1]->DisplayFormat = "#.0" ;

But it seems that something's wrong. Either Fields[n] ir DisplayFormat
is not a member of the left-most member.
This drives me nuts.
Any clue?
Thanks for any help.
Steve

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Accessing Field DisplayFormat at runtime

Post by Ikar » Thu 23 Dec 2004 14:30

DisplayFormat isn't a property of TField , but some its descendants.
You can read details about it in Delphi help.

annlee
Posts: 1
Joined: Sun 12 Feb 2006 19:15

Re: Accessing Field DisplayFormat at runtime

Post by annlee » Sun 12 Feb 2006 19:20

Hi Anonymous,

I have almost exactly the same problem ur having except that im using paradox (not my choice... grrr!) im just wondering if you have found a solution to this already, id appreciate it very much if you can share it with me.

Thanks!
Anonymous wrote:Hi,
I'm trying to set a DisplayFormat to a Field at run time.
It's through an TMyQuery component. Just like for a TMyTable,
when you right-click on a TmyTable, you can access the fields
available and then set a DisplayMask for each of the present
fields.

How can I do this programatically?

I tried (C++)
qryGeneric->Fields->Fields[1]->DisplayFormat = "#.0" ;

But it seems that something's wrong. Either Fields[n] ir DisplayFormat
is not a member of the left-most member.
This drives me nuts.
Any clue?
Thanks for any help.
Steve

Guest

Post by Guest » Thu 25 May 2006 17:34

((TNumericField*)(DataSet->Fields->Fields))->DisplayFormat="0.00";

will work if the field is a numeric field, otherwise it will cause an access violation.

a.alekizoglou
Posts: 32
Joined: Fri 22 Sep 2006 08:32

Post by a.alekizoglou » Fri 29 Jun 2007 08:42

In this case it works correctly, but when you ran an Dataset.Execute the DisplayFormat gets back to ''.

I am using MyDAC 3.55.0.26 with Delphi 7

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Sat 07 Jul 2007 07:04

This happens because each time you open/reopen your dataset, fields are recreated.
Try to create fields at design time.

Post Reply