Search code examples
c#winformsbindingdevexpressxtragrid

How to force grid to propagate value to datasource immediately on change?


I have a DevExpress' XtraGrid which is bound to a collection of objects. I want changes to get into the underlying datasource immediately on change. But the default DevExpress behavior is to put new values into the datasource only when the user has left the cell. So by default when the user types "Hello world" into a cell, the datasource will receive the whole sentence in one go. But I want it to receive "H", "He", "Hel" and so on.

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


Solution

  • This code in the view's CellValueChanging event handler solved the problem:

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