title: Creating a hexadecimal NumericUpDown control
body: <p>I have created a hexadecimal NumericUpDown control by sub-classing the basic NumericUpDown and adding the following method:</p>
  
  <pre><code>protected override void UpdateEditText()
  {
    this.Text = "0x" + ((int) Value).ToString("X2");
  }
  </code></pre>
  
  <p>This works pretty well. The control now shows values in the format:</p>
  
  <blockquote>
    <p>0x3F</p>
  </blockquote>
  
  <p>which is exactly what I was after.</p>
  
  <p>But one thing bothers me: every time the <strong>Text</strong>-property is assigned, a <strong>System.FormatException</strong> is thrown. This doesn't seem to affect the control's functionality, but still I think it's ugly.</p>
  
  <p>This is the top of the callstack:</p>
  
  <blockquote>
    <blockquote>
      <p>MyAssembly.dll!HexNumericUpDown.UpdateEditText() Line 31    C#
          System.Windows.Forms.dll!System.Windows.Forms.NumericUpDown.ValidateEditText()  Unknown
          System.Windows.Forms.dll!System.Windows.Forms.UpDownBase.Text.set(string value) Unknown</p>
    </blockquote>
  </blockquote>
  
  <p>Can I just ignore this exception? Or is there a clean way to get rid of this?</p>