vk33
asked on
TDBEdit float format
Hi!
My problem is the following. I have a *.dbf file with float fields defined. All of them are of certain precision and I see it in the Database Desktop.
I need to format the TDBEdit components connected to the table so that they display trailing zeros. For example, if the precision of the field is 4 and the field contains 1.23, I need 1.2300 to be displayed.
How can I do that? I tried setting up the EditMask for the Table fields, but there are the following problems:
- The mask works only when the field is being edited and I need it to be always displayed with trailing zeros
- I cannot figure out the precision of the field run-time, it always equals 0. Why?
Any help is very much appreciated. Thanks in advance!
My problem is the following. I have a *.dbf file with float fields defined. All of them are of certain precision and I see it in the Database Desktop.
I need to format the TDBEdit components connected to the table so that they display trailing zeros. For example, if the precision of the field is 4 and the field contains 1.23, I need 1.2300 to be displayed.
How can I do that? I tried setting up the EditMask for the Table fields, but there are the following problems:
- The mask works only when the field is being edited and I need it to be always displayed with trailing zeros
- I cannot figure out the precision of the field run-time, it always equals 0. Why?
Any help is very much appreciated. Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Are you using fields definitons at design time? if true, then is in object inspector, in any other case, you can use meikl trick when opening your Dataset.
Edu
Edu
ASKER
Aha, yes, I didn't try casting to specific field types. Thanks!
But still there's the problem remaining - I cannot get the field precision. When I do something like that:
Precision := TFloatField(Table.Fields.F indField(' smth')).Pr ecision
it returns default precision value (15), not the one specified in the dbf-header. How can I deal with that?
If you consider this an off-topic, I can rate this post and open another one, or just raise the points.
But still there's the problem remaining - I cannot get the field precision. When I do something like that:
Precision := TFloatField(Table.Fields.F
it returns default precision value (15), not the one specified in the dbf-header. How can I deal with that?
If you consider this an off-topic, I can rate this post and open another one, or just raise the points.
maybe is problem of the default format for floats, controlled by locale settings.
use the above to format, to get the precision look at:
table1.FieldDefs.Items[1]. Precision;
Fielddefs are the definitions of the fields.
Precision specifies the number of digits of accuracy used to store the field value.
table1.FieldDefs.Items[1].
Fielddefs are the definitions of the fields.
Precision specifies the number of digits of accuracy used to store the field value.
If the above gives you the wrong value, look at table1.FieldDefs.Items[1]. size;
ASKER
Both table1.FieldDefs.Items[0]. Precision and table1.FieldDefs.Items[0]. size return 0.
How should I generally obtain the meta-infomration about the table fields?
Just have a try, you create a simple table with one float column using Database Desktop, specify the size and precision values for this column. Next you launch Delphi, put the TTable component, connect it to the dbf-file previously created, activate the table and see the FieldDefs. I think there's something wrong here, it doesn't display the real size and precision values. And it's the same when you consult the property runtime. :/
How should I generally obtain the meta-infomration about the table fields?
Just have a try, you create a simple table with one float column using Database Desktop, specify the size and precision values for this column. Next you launch Delphi, put the TTable component, connect it to the dbf-file previously created, activate the table and see the FieldDefs. I think there's something wrong here, it doesn't display the real size and precision values. And it's the same when you consult the property runtime. :/
ASKER
Ok, I guess it's better to start another topic.
Thanks for the help!
Thanks for the help!
ASKER