Multiple delete on DynamicRootList bound to a windows datagridview

Multiple delete on DynamicRootList bound to a windows datagridview

Old forum URL: forums.lhotka.net/forums/t/7881.aspx


mikemir8 posted on Monday, October 26, 2009

Hi All,
I have a dynamic root list bound to a datagridview in a windows application. My problem is that when deleting multiple rows from the datagrid only one object in the list receives the DataPortal_DeleteSelf call. The program doesn't throw any exception, it just deletes only one object from the list. Before digging into my code to see what might be wrong, I wanted to check first if this should actually work in a DynamicRootList, or if it's something that's not implemented.

Everything else (inserts, updates) is working ok and, as I mentioned, deletes too, but only one by one.

Thanks,
- Miguel

mikemir8 replied on Monday, October 26, 2009

After doing some testing, I discovered that the culprit seems to be in the following sequence:

* The datagridview calls RemoveItem in EditableRootListBase which, among other things calls item.Delete(), which calls MarkDeleted(), which calls MarkDirty(), which calls OnUnknownPropertyChanged(), which call OnPropertyChanged().

If I skip the call to OnPropertyChanged(), then I get a second call to RemoveItem (for the following deleted row). But if OnPropertyChanged() is called, then there is no second call to RemoveItem.

My understanding of the plumbing of databinding is not as good as I wish, so any help trying to figure this out is much appreciated. Is this a bug or is it by design? Any workaround?

- Miguel

Copyright (c) Marimer LLC