I am using IEditEvents_OnDeleteFeatureEventHandler to handle the processing of some things when the delete happens. However, sometimes I would like to rollback this delete if for instance the "Area is Locked" in another system that doesn't want this area or polygon changed. So I check another system on Delete, and if that system doesn't want the polygon deleted I want to roll back. I have tried AbortOperation, Undo(), UndoOperation(), throw new COMException, and using OriginalShape().
This is the only way I could get the feature to rollback, and it isn't clean. This solution displays my messagebox and then the abortoperation triggers an ArcMap message box that says "The features could not be deleted. OnDelete message to object returned failure [Ag_Field]".
if (IsAreaVerified == "Yes")
{
string warningMessage = "Current field Area Locked, Cannot Delete";
DialogResult dialogResult = MessageBox.Show(warningMessage, "Area Verified", MessageBoxButtons.OK, MessageBoxIcon.Error);
pEditor.AbortOperation();
return;
}
I have tried to get the THROW to work as some documentation says, but to no avail. It is almost like i need a BeforeDelete Handler.
There has to be an easier way to simply ask a user "Are you sure you want to delete this feature"
Matt