I made a very simple sample of a SQLConnexion/SQLDataAdapter/DataSet connected to a SQL Server table. When I edit a record and press on escape, the cell takes the previous value as expected.
Now, when I try to use the CancelEdit button, I don't have the result I expected:
I tought that the CancelEdit button would not only go back in "browse mode" and Cancel all the current changes (like a rollback at record level).
When I try, it doesn't work as expected. So, my question is: What's the real meaning of the CancelEditButton or did I miss something?
My objective is to make my own list implementing IBindingList with IEditableObject items. All the navigator and grids works perfectly except the CancelEdit... That why I made some test using 'regular' dataset.
If I understand you correctly, you are talking about the standalone DataNavigator's CancelEdit button. If so, the problem is not with the standalone navigator. When you are trying to press the CancelEdit button, the Grid loses focus and as a result posts the current changes to the data source before the Cancel button is pressed. Therefore this button doesn't have any effect. The mentioned button will work correctly only if you are using the standalone DataNavigator along with standalone editors. In the case of using a Grid, you should use the embedded navigator instead.
Great thank you!
One related sub-question: Can you tell me what happens in the embedded navigator when the user click on Cancel? (after a validation problem for example). In a ADO connected dataset it undo the changes, (which is natural of course). I mean, what is called. (not the effects)
I ask you that because I have implemented my own datasource (as a class implementing IBindingList). The items of my datasource implements IEditableObject. I tought that the Cancel button would call CancelEdit method from the IEditableObject, but it doesn't seems to. So, maybe my implementation is wrong, or I misunderstood something.
So, does the cancel button of the embedded calls the methods of the IEditableObject or does it do the "undo" in another way?
(I'm writting some Winform Control to be able to use BDS2006 with ECO with the XtraGrids in a nice and easy way).
When I edit the cell of a grid and press Cancel, it does undo the changes. But when I have a validation problem (using ValidateRow / Set Column Error and ExceptionMode= ExceptionMode.noAction) and I press on escape the wrong data is well validated and the 'wrong' data is posted.
Thank you again,
When you click the cancel button, the following code is executed (ColumnView.cs - ColumnView.DoNavigatorAction(NavigatorButtonType type) ):
The CancelUpdateCurrentRow calls the CancelCurrentEdit() method of the underlying CurrencyManager object. After it the data controller calls the CancelEdit method of the corresponding IEditableObject object.
Sorry, but I don't quite understand how to replicate the issue. Please review the GridIBindingList tutorial shipped with the installation which demonstrates how to implement this functionality. If it doesn't help, please attach a sample project which demonstrates the issue. I'll review it and try to provide you with an exact solution.