Page 1 of 1

Accessing Field DisplayFormat at runtime

Posted: Wed 22 Dec 2004 15:00
by Guest
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

Re: Accessing Field DisplayFormat at runtime

Posted: Thu 23 Dec 2004 14:30
by Ikar
DisplayFormat isn't a property of TField , but some its descendants.
You can read details about it in Delphi help.

Re: Accessing Field DisplayFormat at runtime

Posted: Sun 12 Feb 2006 19:20
by annlee
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

Posted: Thu 25 May 2006 17:34
by Guest
((TNumericField*)(DataSet->Fields->Fields))->DisplayFormat="0.00";

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

Posted: Fri 29 Jun 2007 08:42
by a.alekizoglou
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

Posted: Sat 07 Jul 2007 07:04
by Antaeus
This happens because each time you open/reopen your dataset, fields are recreated.
Try to create fields at design time.