public void Print(bool inShowPreview) { try { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = myReportName; InitPrinting( ref myPrintDoc ); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( this.PrintReport ); if ( inShowPreview ) { curPreviewDialog.Document = myPrintDoc; curPreviewDialog.WindowState = FormWindowState.Normal; curPreviewDialog.ShowDialog(); } else { myPrintDoc.Print(); String curPrintString = myPrintDoc.ToString(); if (curPrintString.Length > 0) { MessageBox.Show( curPrintString ); } } } } catch ( Exception ex ) { MessageBox.Show( "Exception encountered in print method of FormReportPrinter" + "\n Exception: " + ex.ToString() ); } }