Printing Without A Dialog Box

Windows Forms User's Guide > Howto: Print

It is also possible to print a document without user interaction. This is done by assigning all required options to a PrintDocument object, and then passing it to the TextControl.Print method. This code sample will send page 1 of a document to the default printer:

private void mnuFile_Print_WithoutDialog_Click(object sender, System.EventArgs e)
    PrintDocument myPrintDocument = new PrintDocument();
    myPrintDocument.PrinterSettings.FromPage = 1;
    myPrintDocument.PrinterSettings.ToPage = 1;
[Visual Basic]
Private Sub mnuFile_Print_WithoutDialog_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mnuFile_Print_WithoutDialog.Click
    Dim myPrintDocument As New System.Drawing.Printing.PrintDocument()
    myPrintDocument.PrinterSettings.FromPage = 1
    myPrintDocument.PrinterSettings.ToPage = 1
End Sub