title: How to Automatically Print Crystal Reports with Default Printer
body: <p>I'm Having a problem on automatically printing reports using crystal reports. Below is my code snippet</p>
  
  <p>It's Printing but the problem is it ignore the  <strong>ReportView.SelectionFormula</strong> (Which only containing page 1 to Page 10) But printing the all the records in the datasource.</p>
  
  <pre><code> ConnectionInfo ConInfo;
          try
          {
              this.Cursor = Cursors.WaitCursor;
  
  
              ConInfo = ConfigureCrystalReportsRD();
  
              ReportDocument.Load(reportToLoad);
              ReportView.ReportSource = ReportDocument;
              SetDBLogonForReportRD(ConInfo, ReportDocument);
              SetReserveFormulaValue();
  
  
              string strReportFilter = "";
  
              strReportFilter = ReportDocument.DataDefinition.RecordSelectionFormula;
  
              if (strReportFilter != "" &amp;&amp; formulaFields != "")
              {
                  ReportView.SelectionFormula = strReportFilter + " and " + formulaFields;
              }
              else
              {
                  ReportView.SelectionFormula = formulaFields;
              }
  
  
              if (isPint == true)
              {
                  this.Cursor = Cursors.WaitCursor;
                  System.Drawing.Printing.PrinterSettings printer = new System.Drawing.Printing.PrinterSettings();
                  System.Drawing.Printing.PageSettings page = new System.Drawing.Printing.PageSettings();
                  ReportDocument.PrintToPrinter(printer,page,true);
                  MessageBox.Show("Printing at " + printer.PrinterName + " .....");
                  this.Cursor = Cursors.Default;
  
              }
  
              this.Cursor = Cursors.Default;
  
  
          }
          catch (Exception e)
          {
              oGenMethod.ErrorMessage(e.Message, FORMID, "PreviewReport");
          }
  </code></pre>
  
  <p><strong>Note:</strong> </p>
  
  <p><strong>ReportView.PrintReport()</strong> does the job successfully but it pops-up the Printer Settings</p>
  
  <p>Thank you in advance!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>What wrong in my code is that i only set the RecordSelectionFormula at ReportViewer Object not on the Report Document. </p>
  
  <pre><code>ConnectionInfo ConInfo;
  
          string strReportFilter = "";
  
          try
          {
              this.Cursor = Cursors.WaitCursor;
  
  
              ConInfo = ConfigureCrystalReportsRD();
  
              ReportDocument.Load(reportToLoad);
              ReportView.ReportSource = ReportDocument;
              SetDBLogonForReportRD(ConInfo, ReportDocument);
              SetReserveFormulaValue();
  
  
              strReportFilter = ReportDocument.DataDefinition.RecordSelectionFormula;
  
              if (strReportFilter != "" &amp;&amp; formulaFields != "")
                  ReportView.SelectionFormula = strReportFilter + " and " + formulaFields;
              else
                  ReportView.SelectionFormula = formulaFields;
  
  
              ReportDocument.DataDefinition.RecordSelectionFormula = ReportView.SelectionFormula;
  
  
  
  
              if (isPint == true)
              {
                  this.Cursor = Cursors.WaitCursor;
                  ReportDocument.PrintToPrinter(1, true, 0, 0);
                  this.Cursor = Cursors.Default;              
  </code></pre>
  
  <p>}</p>