I have requirement to apply different mask on each cell of grid and based on format assigned to cell and in th
Like if format is >>,999.99>>
Then it means maximum number is 5 and maximum precision is 4 but if user is entering number less than 3 digits or less than 2 precsion then we need to append zero.
8.8 --> 008.80
12.2 -> 012.20
324.45 --> 324.45
1234.5 -> 1234.50
4.55 --> 004.55
any idea how can I create a mask to achieve this.
Using a mask would be difficult since you mentioned that the maximum amount of numbers that the user can enter should be 5, which would contradict with the following case:
1234.5 -> 1234.50 if a mask like the following is used : “nnn.nn”, the number would become 123.45 instead. If you would like to have 4 digit number before the “.” then a mask like the following could work “nnnn.nn”.
An alternative to this would be to not use a mask and apply a format to the column that would hold the values. This format (“000.00”) would include leading zeroes as well as adding a zero after the decimal point. The MaxLength property of the column needs to be used to limit the number of digits entered this number should be 6 instead of 5, since the decimal point is also counted. Because of this the input should be validated in a way that meets the requirements of your application, since the user may not use a decimal point and the number might be greater than 9999.9.
I am attaching a small sample that demonstrates what I have explained above. Please test the attached sample and let me know if you have any questions or concerns.
Regards, Ivan Kitanov