I've noticed that when a GridControl has an XPCollection as data source, it calls the individual object's BeginEdit() method on entering the appropriate row and EndEdit() when leaving the row. With the current implementation of XPO this forces an XPObject to save even if we haven't made changes in the grid.
This has the unfortunate side-effect that if I have the object also visible in a separate form (non-modal) and being edited there that the changes are pushed to the database when the user might still be editing and may want to back out of the changes later (and will no longer be able to).
I've seen the article in KnowledgeBase saying that this behaviour could be dealt with by overriding BeginEdit()/EndEdit() at the object level, but I'm concerned that this is semantically the wrong place.
Is there anyway of preventing the grid making these calls when in read-only mode? Seeing as it's not editing does it really need to call these methods? I understand that it might to keep synchronisation with the objects but there must be softer ways of doing this.
I look forward to your thoughts.
Best regards
Colin B
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.
The problem has nothing to do with the XtraGrid. Please put a break point into the BeginEdit method of your object and examine the call stack when the execution is stopped. You will see that the CurrencyManager switches the object to edit mode. This is the specifics of .NET Windows Forms data binding.
As a solution, please try to call the CurrencyManager.CancelCurrentEdit method right after binding the grid to data (you can find out the best place wherefrom to call the CancelCurrentEdit when analyzing the call stack of the BeginEdit method call).