I created a property called IsBrandNew (as suggested in a post) that is true on the creation of a child object and is set to false after the first applyedit is called. I use the addnew method on my collection object that adds the new object to the collection the passes it to a form. This way on the first use of the new child object if they cancel I remove the object from the collection. The problem is, if the user saves the object I set the flag to false then finish the applyedit. If the user calls up the same object again and cancels for some reason the IsBrandNew flag is true and the object is removed from the collection.
I have my own baseobjects that inherit from CSLA objects and it is in this businessbase object that I have declared my isbrandnew variable and property and also have overriden the Apply and Cancel methods to deal with the collections.
Friend Property IsBrandNew() As Boolean Get Return bIsBrandNew End Get Set(ByVal value As Boolean)bIsBrandNew = value
End Set End PropertyPublic
Shadows Sub ApplyEdit() If Me.IsNew AndAlso Me.IsChild And Me.IsBrandNew Then Try Me.IsBrandNew = False Catch ex As Exception ' if we are here then probably the child had no parent object End Try End If MyBase.ApplyEdit() End Sub Public Shadows Sub CancelEdit() Try If Me.IsChild = True AndAlso Me.IsNew = True AndAlso Me.IsBrandNew = True Then Me.Parent.remove(Me) End If Catch ex As Exception End Try MyBase.CancelEdit() End SubHopefully someone can see what I am doing wrong.
Thanks
Copyright (c) Marimer LLC