void System.ComponentModel.IEditableObject.CancelEdit() { if (_bindingEdit) { CancelEdit(); if (IsNew && _neverCommitted && EditLevel <= EditLevelAdded) { if (Parent != null) { Parent.RemoveChild(this); } } } }
/// <summary> /// Allow data binding to cancel the current edit. /// </summary> /// <remarks> /// Data binding may call this method many times. Only the first /// call to either IEditableObject.CancelEdit or /// IEditableObject.EndEdit /// should be honored. We include extra code to detect this and do /// nothing for subsequent calls. /// </remarks> void System.ComponentModel.IEditableObject.CancelEdit() { if (_bindingEdit) { CancelEdit(); if (IsNew && _neverCommitted && EditLevel <= EditLevelAdded) { // we're new and no EndEdit or ApplyEdit has ever been // called on us, and now we've been cancelled back to // where we were added so we should have ourselves // removed from the parent collection if (Parent != null) { Parent.RemoveChild(this); } } } }