Customizing The Print Dialog Box

Windows Forms User's Guide > Howto: Print

By default, the print dialog box will be displayed with default options, which is fine for most applications. Should you need to configure the print dialog, for instance to enable or disable options like AllowPrintToFile, ShowHelp, or ShowNetwork, you can use the TextControl.Print method with an application provided dialog box. This code sample will open a print dialog box with the AllowPrintToFile and AllowSomePages options disabled:

private void mnuFile_Print_WithCustomizedDialog_Click(object sender, System.EventArgs e)
    PrintDialog myPrintDialog = new PrintDialog();
    PrintDocument myPrintDocument = new PrintDocument();
    myPrintDialog.Document = myPrintDocument;
    myPrintDialog.AllowSomePages = false;
    myPrintDialog.AllowPrintToFile = false;
    myPrintDialog.PrinterSettings.FromPage = 1;
    myPrintDialog.PrinterSettings.ToPage = txTextControl1.Pages;
    if (myPrintDialog.ShowDialog() == DialogResult.OK )
[Visual Basic]
Private Sub mnuFile_Print_WithCustomizedDialog_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mnuFile_Print_WithCustomizedDialog.Click
    Dim MyPrintDialog As New PrintDialog()
    Dim MyPrintDocument As New System.Drawing.Printing.PrintDocument()
    MyPrintDialog.Document = MyPrintDocument
    MyPrintDialog.AllowSomePages = False
    MyPrintDialog.AllowPrintToFile = False
    MyPrintDialog.PrinterSettings.FromPage = 1
    MyPrintDialog.PrinterSettings.ToPage = TextControl1.Pages
    If MyPrintDialog.ShowDialog() = DialogResult.OK Then
    End If
End Sub