tags:

views:

94

answers:

2

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
+1 for the EditMask as the OP seems interested in limiting input values (as opposed to just formatting the values for display).
Marjan Venema
How can I ged rid of the underscores and '.' in the grid because the grid by default has a value of __._?
rajeem_cariazo
+1  A: 

I usually use:

TFloatField(Myds.FieldByName('MyField')).DisplayFormat := '#.##';

This should work with every type of TDataset

Mohammed Nasman