The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

How to: Control Automatic Saving of Objects when Editing in a Grid

  • 2 min to read

When an XtraGrid control is bound to an XPCollection, persistent objects within the collection automatically save their state immediately after editing is finished. This is accomplished via the default IEditableObject interface implementation provided by the XPBaseObject class. In essence, the object's XPBaseObject.Save method is called after editing is finished (IEditableObject.EndEdit()) and the static XPBaseObject.AutoSaveOnEndEdit field is set to true. To disable automatic saving, do one of the following.

  • Set the static XPBaseObject.AutoSaveOnEndEdit field to false.

    
    using DevExpress.Xpo;
    
    public class Contact : XPObject {
    ...
    }
    
    // ...
    Contact.AutoSaveOnEndEdit = false;
    
  • Override the default IEditableObject.EndEdit() method implementation. If you want the total control over object saving, you can override the entire IEditableObject interface implementation as shown below.

    
    using DevExpress.Xpo;
    
    public class Contact : XPObject {
    ...
        protected override void BeginEdit() {}
        protected override void EndEdit() {}
        protected override void CancelEdit() {}
    ...
    }
    

After this, you need to manually save the changes to the underlying database, when necessary, via the XPBaseObject.Save method call.

See Also