public override void DetachEditingControl() { DataGridView dataGridView = this.DataGridView; if (dataGridView == null || dataGridView.EditingControl == null) { throw new InvalidOperationException("Cell is detached or its grid has no editing control."); } NumeroTextBox numEditBox = dataGridView.EditingControl as NumeroTextBox; if (numEditBox != null) { numEditBox.ClearUndo(); // avoid interferences between the editing sessions } base.DetachEditingControl(); }
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); NumeroTextBox numEditBox = this.DataGridView.EditingControl as NumeroTextBox; if (numEditBox != null) { numEditBox.BorderStyle = BorderStyle.None; numEditBox.CantidadDecimales = this.DecimalLength; numEditBox.PermiteNegativos = this.AllowNegative; string initialFormattedValueStr = initialFormattedValue as string; if (string.IsNullOrEmpty(initialFormattedValueStr)) { numEditBox.Text = "0"; } else { numEditBox.Text = initialFormattedValueStr; } } }