Hello all,
I have a regular dropdown list (WinForms) with a BindingList<T> as its data source and I want to edit the dropdown's items usign the UltraGrid (8.3). I want also to commit the changes (changed item names, new items added, items removed) if I press a "save" button only (it would be nice to have a "reset" functionality here in order to cancel all the changes).
In order to achive this, I use the same data source for both, the dropdown list and the ultragrid (so the ultragrid gets a BindingList<T> object). The problem is that once the edited cell is left, the corresponding datasource item is updated and there is no way to restore it to its original value.
I execute this code for the "commit" button:
this.ultraGrid1.UpdateData();
having this property set:
this.ultraGrid1.UpdateMode = UpdateMode.OnUpdate;
How should I proceed in order to make it work as I described?
Thanks!
Hi,
You can't do this. At least, not with a BindingList<T>.
The UpdateMode.OnUpdate setting was carried over from the ActiveX version fo the UltraGrid. But the CurrencyManager in DotNet doesn't really allow this setting to work because any time the CurrencyManager's current Position is change, it does an implicit EndEnd and commits the changes to the previous current row.
So the only way to do something like this would be to use a DataSource that tracks changes like a DataTable. With the DataTable, you could call CancelUpdate to revert any pending changes. BindingList<T> doesn't have this ability as far as I am aware.
Having said all that, there may actually be a way to get the OnUpdate setting to work. A while back, a new property was added to the grid called SyncWithCurrencyManager. Setting this to false would prevent the grid from changing the current position of the CurrencyManager when you change the ActiveRow in the grid. So theoretically, this would negate the issue of the EndEdit getting called by the CurrencyManager.
This is just a theory - I have not tested it. And you still may run into a problem is something else changes the Position of the CurrencyManager. For example, the dropdown list might change the position. But it might be worth trying it.
Hi Mike,
I tested setting the SyncWithCurrencyManager to false in an attempt to make the OnUpdate mode work. It doesn't work. The CellUpdate events still fire. Just wanted to post that bit of knowledge for those following or discovering the thread.
Let me know how it goes. I'm curious to know if turning off SyncWithCurrencyManager allows UpdateMode.OnUpdate to work.