I've a BO derived from BusinessBase(Of T) wich has an editable child collection derived from BusinessListBase(Of T,C).
I've some code that toggles the AllowRemove value in this child collection, so I can add/remove childs and then set AllowRemove = False to block further editing
In that case calling the root BO .CancelEdit method throws a "Method not supported" exception. I've found that the CancelEdit method may call BindingList.RemoveAt (index) wich fails if AllowRemove = False.
To solve this problem I've changed the method BusinessListBase.UndoChanges from:
If
child.EditLevelAdded > mEditLevel Thento:
If child.EditLevelAdded > mEditLevel Then
Dim CurrentAllowRemove As Boolean = Me.AllowRemove
Try
Me.AllowRemove = True
RemoveAt(index)
Finally
Me.AllowRemove = CurrentAllowRemove
End Try
End If
This way I force AllowRemove=True when calling CancelEdit/UndoChanges (but not outside it, I think that the exception thrown is ok if Remove/RemoveAt gets called directly).
I'd like to discuss this issue, what do you think about that code change ?
Regards,
Jacobo
Copyright (c) Marimer LLC