KB Article A352
Visible to All Users

How to save the currently edited row without moving to another row

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 Basic
If Not (View.PostEditor() AndAlso View.UpdateCurrentRow()) Then
C#
void Form_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = !(View.PostEditor() && View.UpdateCurrentRow()); }
Visual Basic
Private 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

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.