Skip to content

PdfDocumentView.BeforeAnnotationDelete Event

Occurs before an annotation is deleted using the DEL key or the Delete menu item in annotation's default context menu.

C#
public EventHandler<PdfVisualAnnotationDeleteEventArgs> BeforeAnnotationDelete;

Event Type

EventHandler<PdfVisualAnnotationDeleteEventArgs>

Remarks

This event is raised when the user hits the DEL key or selects the Delete menu item (Delete annotation) in the annotation's default context menu.
It allows the application to cancel the annotation deletion by setting the PdfVisualAnnotationDeleteEventArgs.AllowDelete property to false.
The code below shows how to handle the event and control the annotation deletion based on user input:

C#
1
2
3
4
private void documentView_BeforeAnnotationDelete(object sender, PdfVisualAnnotationDeleteEventArgs e)
{
   e.AllowDelete = MessageBox.Show("Are you sure you want to delete the annotation?", "Application Title", MessageBoxButtons.YesNo) == DialogResult.Yes;
}
The annotation deletion is disabled by default, the PdfVisualAnnotationDeleteEventArgs.AllowDelete property is set initially to false. The application must explicitly allow the deletion by setting the property to true in the event handler.