Advanced 10 min read Control #20

PrintPreviewDialog Control

PrintPreviewDialog shows a preview of what will be printed before sending it to the printer.

What is a PrintPreviewDialog?

PrintPreviewDialog displays a print preview of a PrintDocument. Users can see how the document will look before printing, zoom in/out, and navigate through pages.

Code Example

// Show print preview
private void btnPreview_Click(object sender, EventArgs e)
{
    // Set the document to preview
    printPreviewDialog1.Document = printDocument1;
    
    // Show the preview dialog
    printPreviewDialog1.ShowDialog();
}

// Configure the preview
printPreviewDialog1.ShowHelp = true;
printPreviewDialog1.UseAntiAlias = true;

Exercise

Task: Create a print preview application.

  1. Add a PrintDocument with some content.
  2. Add a PrintPreviewDialog.
  3. Add a Button: "Preview".
  4. Show the preview when clicked.
  5. Add a Button to print from the preview.
Key Takeaway

PrintPreviewDialog lets users see what will be printed. Always provide preview before printing to prevent wasted paper.