How do I force the grid to immediately pass the value to the data source when changed?

I have a DevStress XtraGrid associated with a collection of objects. I want the changes to go straight to the underlying change data source. But DevExpress's default behavior is to only enter new values โ€‹โ€‹into the data source when the user has left the cell. Therefore, by default, when the user enters "Hello world" into a cell, the data source will receive the entire offer in one go. But I want him to get "H", "He", "Hel", etc.

I tried to call PostEditor () in the CellValueChanging event handler, but it didn't help. Any other ideas?

+3


source to share


3 answers


This code, in the CellValueChanging event handler view, solved the problem:



    private void OnCellValueChanging(object sender, CellValueChangedEventArgs e)
    {
        _gridView.SetFocusedRowCellValue(_gridView.FocusedColumn, e.Value);
    }

      

0


source


Grid- in-place editors provide an EditValueChanged event that fires when an end user types into the editor or changes its value in some way. You can handle this event to post the edited value to the data source.
Therefore, I recommend using the following approach:



    //...
    gridView.ShownEditor += gridView_ShownEditor;
    gridView.HiddenEditor += gridView_HiddenEditor;
}
DevExpress.XtraEditors.BaseEdit gridViewActiveEditor;
void gridView_ShownEditor(object sender, EventArgs e) {
    gridViewActiveEditor = gridView.ActiveEditor;
    gridViewActiveEditor.EditValueChanged += ActiveEditor_EditValueChanged;
}
void gridView_HiddenEditor(object sender, EventArgs e) {
    gridViewActiveEditor.EditValueChanged -= ActiveEditor_EditValueChanged;
}
void ActiveEditor_EditValueChanged(object sender, EventArgs e) {
    gridView.PostEditor();
}

      

+9


source


I think CellValueChanging is a trap event, but instead of PostEditor()

tryUpdateCurrentRow().

+2


source







All Articles