title: What is the best way to format an edit box that represents a numeric value?
body: <p>In my c# program I have a very simple DevExpress edit box that represents a numeric value.</p>
  
  <p><img src="https://i.stack.imgur.com/bemgU.png" alt="enter image description here"></p>
  
  <p>What I would like to do is to add a restriction on the number of decimals in such a way that:</p>
  
  <ul>
  <li>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.</li>
  <li>If a programmer sets the edit box' text, the value is rounded so that it meets the requirements. </li>
  </ul>
  
  <p>What is the best way to do this?</p>
  
  <p>Ps.: I thought this would solve my problem:</p>
  
  <pre><code>valueTextEdit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
  valueTextEdit.Properties.DisplayFormat.FormatString = "#.000;[#.000];0.000";
  </code></pre>
  
  <p>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. </p>