How to: Control Automatic Saving of Objects when Editing in a Grid
- 2 minutes 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.
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.
After this, you need to manually save the changes to the underlying database, when necessary, via the XPBaseObject.Save method call.