Skip to content

PdfDocumentView.BeforePageDelete Event

Occurs before a page is deleted using the Delete menu item in page's default context menu.

C#
public EventHandler<PdfVisualPageDeleteEventArgs> BeforePageDelete;

Event Type

EventHandler<PdfVisualPageDeleteEventArgs>

Remarks

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

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