title: Custom DataGridViewColumn value disappears after loosing focus
body: <p>I have created a custom DataGridViewColumn for my project in WinForms. The control renders perfectly, but once I input the value and move to another cell, the value disappears and comes up as null when I check in CellEndEdit.</p>
  
  <p>Following is the code:</p>
  
  <pre><code>class NumericEditControl : NumericTextBox, IDataGridViewEditingControl
  {
      DataGridView dataGridView;
      private bool valueChanged = false;
      int rowIndex;
  
      public NumericEditControl()
      {
          this.Value = 0;
      }
  
      public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
      {
          this.Font = dataGridViewCellStyle.Font;
          this.ForeColor = dataGridViewCellStyle.ForeColor;
          this.BackColor = dataGridViewCellStyle.BackColor;
      }
  
      public DataGridView EditingControlDataGridView
      {
          get
          {
              return dataGridView;
          }
          set
          {
              dataGridView = value;
          }
      }
  
      public object EditingControlFormattedValue
      {
          get
          {
              return this.Value;
          }
          set
          {
              this.Value = Convert.ToDouble(value);
          }
      }
  
      public int EditingControlRowIndex
      {
          get
          {
              return rowIndex;
          }
          set
          {
              rowIndex = value;
          }
      }
  
      public bool EditingControlValueChanged
      {
          get
          {
              return valueChanged;
          }
          set
          {
              valueChanged = value;
          }
      }
  
      public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
      {
          switch (keyData &amp; Keys.KeyCode)
          {
              case Keys.Left:
              case Keys.Up:
              case Keys.Down:
              case Keys.Right:
              case Keys.Home:
              case Keys.End:
              case Keys.PageDown:
              case Keys.PageUp:
                  return true;
              default:
                  return !dataGridViewWantsInputKey;
          }
      }
  
      public Cursor EditingPanelCursor
      {
          get
          {
              return base.Cursor;
          }
      }
  
      public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context)
      {
          return EditingControlFormattedValue;
      }
  
      public void PrepareEditingControlForEdit(bool selectAll)
      {
  
      }
  
      public bool RepositionEditingControlOnValueChange
      {
          get { return false; }
      }
  
  }
  </code></pre>
  
  <p>The cell class is as follows:</p>
  
  <pre><code>public class NumericCell : DataGridViewTextBoxCell
  {
      public NumericCell()
          : base()
      {
          this.Style.Format = "0";
      }
  
      public override void InitializeEditingControl(int rowIndex, object
      initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
      {
          // Set the value of the editing control to the current cell value.
          base.InitializeEditingControl(rowIndex, initialFormattedValue,
              dataGridViewCellStyle);
          NumericEditControl ctl =
              DataGridView.EditingControl as NumericEditControl;
          // Use the default row value when Value property is null.
          if (this.Value == null)
          {
              ctl.Value = 0;
          }
          else
          {
              ctl.Value = (double)this.Value;
          }
      }
  
      public override Type EditType
      {
          get
          {
              return typeof(NumericEditControl);
          }
      }
  
      public override Type ValueType
      {
          get
          {
              return typeof(double);
          }
      }
  
      public override object DefaultNewRowValue
      {
          get
          {
              return "0";
          }
      }
  
  
  }
  </code></pre>
  
  <p>And finally the DataGridViewColumn</p>
  
  <pre><code>public class NumericDataColumn : DataGridViewColumn
  {
      public NumericDataColumn()
          : base(new NumericCell())
      {
      }
  
      public override DataGridViewCell CellTemplate
      {
          get
          {
              return base.CellTemplate;
          }
          set
          {
              if (value != null &amp;&amp;
                  !value.GetType().IsAssignableFrom(typeof(NumericCell)))
              {
                  throw new InvalidCastException("Must be a Numeric");
              }
              base.CellTemplate = value;
          }
      }
  }
  </code></pre>
  
  <p>In the designer</p>
  
  <pre><code>private GridControl.NumericDataColumn colRoll;
  </code></pre>
  
  <p>It renders the control but I cannot understand why the value is disappearing. Can you please help me out</p>