In my c# program I have a very simple DevExpress edit box that represents a numeric value.
What I would like to do is to add a restriction on the number of decimals in such a way that:
- Users cannot type, paste or in any other way enter a value that contains more than a predefined number of decimals. I fact I just want to editbox to ignore the user's typing as soon as 3 decimals have been entered.
- If a programmer sets the edit box' text, the value is rounded so that it meets the requirements.
What is the best way to do this?
Ps.: I thought this would solve my problem:
valueTextEdit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
valueTextEdit.Properties.DisplayFormat.FormatString = "#.000;[#.000];0.000";
But it doesn't seem to do anything. I can still enter values with 10 decimals. Also in code I can set the edit box text to a value with a larger number of decimals.