Custom EditingControl doesn't set the Value



kind of a continuation of this thread from me:

Back then I solved it by simply extending DataGridViewTextBoxEditingControl, but now I have to extend a different control, so I build a small example, but it doesn’t work.

I looked through these threads: and and copied parts of the solutions. There seems to be no code where the Textbox manually sets the Value of the Cell.
One Example even says “// Not needed, the DataGridView will store the Text property in the cell’s value.”

But it doesn’t work for me.

During CellEndEdit Eventhandlers, the Value is the old one. CellValueChanged is never hit. Visually the new one is shown, until I start editing it again.

I’m now using 3.0.10. Do Custom Editors need to set Cell Values manually? Why does no example show that this is needed? The interface and the examples of Windows Forms EditingControls seem to work quite differently as well.

I added some sample code. Most things in one file. A standard page that should work on it’s own in a wisej project, when loaded with Application.MainPage = new DataGridEditorPage();

Thanks in advance.

  • You must to post comments

It’s a lot easier than the code you attached. There are two ways to use custom editors:

Light way:  column1.Editor = new TextBox()

This is all you need. TextBox can be MyTextBox() or whatever control you like. When a cell in column1 enters edit mode the single instance (for that column) of the edit control is moved to that cell, initialized with the cell formatted value and then the Text property of the editor is parsed and stored in the cell.

More involved way: Custom column, custom cell, and custom editor implementing IDataGridViewEditingControl. Of course there are also ways in between where you can change a cell type in a standard column, or change only a single cell, etc.

// custom column using a custom cell
public class RICStandardColumn : DataGridViewColumn {
    public RICStandardColumn() : base(new RICStandardCell()) {

// custom cell using a custom editor
public class RICStandardCell : DataGridViewCell {
   public override Type EditType { get { return typeof(RICStandardEditingControl); } }

   // optional override
   public override void InitializeEditingControl(Control editor, DataGridViewCellStyle style) {
    // initialize the editing control here.
    base.InitializeEditingControl(editor, style);

// custom editor implementing IDataGridViewEditingControl
// if you extend an existing class like DataGridViewTextBoxEditingControl just call the base for the initialization.
public class RICStandardEditingControl : TextBox, IDataGridViewEditingControl {

  public DataGridView DataGridView { get; set; }

  public void ApplyCellStyleToEditingControl(DataGridViewCellStyle style) {

  public string GetEditingControlFormattedValue() {
   return this.Text;

  public void PrepareEditingControlForEdit(bool selectAll) {

  protected override void OnTextChanged(EventArgs e) {

    // this is necessary to inform the grid that something has been edited or
    // the cell is never dirty.

    // ONLY when implementing IDataGridViewEditingControl, otherwise Wisej
    // will automatically use TextChanged for light implementation simply assigning the Editor property
    // of a column. Cannot mix the two.


  • Sascha Lorenz
    Thank you. I wasn’t aware that it gets so much easier, if you just use Controls instead of Editing Controls. With your help my current solution is reducing my Custom Columns and Cells to the bare minimum (because there is some other stuff in there I want to keep) and setting the Editor in the constructor to a Control that extends TextBox and not EditingControl. I will have CheckBoxes which need to save strings or numbers, so I assume I can use the properties “FalseValue” and “TrueValue” for that. I don’t really understand what you mean with your last comment in your code. I understand that why it needs to be set dirty, but what exactly can’t be mixed?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.