I have a typical InvoiceHeader / InvoiceDetail scenario.
My InvoiceHeader class has a property called MyInvoiceDetails representing its associated InvoiceDetail records. I am overriding the OnChildChanged method in InvoiceHeader to handle additions to, changes in, and deletions from MyInvoiceDetails.
It works perfectly for additions and changes. However, when deleting an InvoiceDetail from MyInvoiceDetails, e.ChildObject represents the InvoiceDetailCollection: I would expect it to represent the deleted InvoiceDetail instead.
Is this by design? If not, I guess I've found a bug. If indeed it is by design, please advise as to what other approach I should use to trigger business logic associated with the deletion of an item from a child collection in my scenario.
There is an event raised by BusinessListBase called RemovingItem. You should be able to hook into that.
Martin.
Reading through Rocky's book on this topic, it is clear that OnChildChanged is there to be overridden in a Parent class to indicate to the parent what child has changed, and what detail about that child has changed, so that business logic can be executed accordingly.
This "indication" of the change is indeed done perfectly in the ChildChangedEventArgs parameter when adding to and changing items in a child collection. I therefore can't help but feel that it is not by design that when deleting a record from the child collection, all that ChildChangedEventArgs reports is the changed child collection, without any indication of which item was deleted from the collection.
Copyright (c) Marimer LLC