I have a DataGridView bound to a BindingSource which is bound to a collection of objects. In the BindingSource's AddingNew event, I will create a new object, like this:
PrivateSub BindingSource_AddingNew(senderAsObject, e As System.ComponentModel.AddingNewEventArgs)Handles BindingSource.AddingNew
Dim newSample AsNewtbFFResult
newSample.TS = DateTime.Now
e.NewObject = newSample
EndSub
The problem is when user decide to cancel adding new row by hitting Esc. New row is removed from DataGridView but it’s not removed from my tbFFResultcollection.
I can remove empty object in OnSavingChangesevent, but the real problem is when user fill new row correctly and then hit Esc (without changing row before). Row is removed from Grid (user don’t want it) but it is still in tbFFResultcollection.
How can I remove such deleted object from my collection ?
Thank You for any help,
Larry