Description:
How do I save changes made to the currently edited grid row without moving to another row?
Answer:
Our GridControl automatically saves all the introduced changes when it loses focus, when focus is moved to another row or a new view is focused.
On the other hand, to ensure that all the introduced changes are posted to the underlying source when switching between cells in the same row, it is necessary to invoke the PostEditor and UpdateCurrentRow methods.
You can invoke these methods, for instance, when you need to save the changes on a button click.
It is also possible to prevent a form from being closed if the introduced changes aren't acceptable. For this, simply check the following condition in the Form.FormClosing event handler and set the e.Cancel parameter to true if this condition is satisfied:
C#if (!(View.PostEditor() && View.UpdateCurrentRow()))
Visual BasicIf Not (View.PostEditor() AndAlso View.UpdateCurrentRow()) Then
C#void Form_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = !(View.PostEditor() && View.UpdateCurrentRow());
}
Visual BasicPrivate Sub Form_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
e.Cancel = Not (View.PostEditor() AndAlso View.UpdateCurrentRow())
End Sub
See also:
Posting Data to a Connected Database