I have a DBGrid which is connected to a ClientDataSet and it has a field UnitCost. What I want to do is to limit to 2 decimal places every value that will be assigned to that field. Is there an easier way to do this other than validating every input value?
+4
A:
You can try to set ClientDataset.FieldByName('UnitCost').EditMask := '#.00';
Linas
2010-09-15 08:17:44
+1 for the EditMask as the OP seems interested in limiting input values (as opposed to just formatting the values for display).
Marjan Venema
2010-09-15 11:52:32
How can I ged rid of the underscores and '.' in the grid because the grid by default has a value of __._?
rajeem_cariazo
2010-09-16 06:39:53
+1
A:
I usually use:
TFloatField(Myds.FieldByName('MyField')).DisplayFormat := '#.##';
This should work with every type of TDataset
Mohammed Nasman
2010-09-15 08:34:32