Ur Marcelino
Ur Marcelino

Reputation: 61

Auto Print Report with Report Viewer

Is there a way to print a document without viewing it in reportviewer? I managed to display it first in the reportviewer, but I want to print it directly after clicking a button; just like printing a receipt in a POS system.

My process in viewing the report: I add a DataSet with TableAdapter and Report in my project and link it together. With my button, I just call this statements to view my report.

this.DataTable1TableAdapter.Fill(this.myDataSet.DataTable1, transacID);
this.reportViewer1.RefreshReport();

How do I print my report without clicking the print button on the reportviewer? I am looking for something like this:

this.reportViewer1.Print();

I also tried to instantiate the PrintDocument class. It has a Print() method, It also requires a document name to print a specific document, If I could just retrieve the document name of my report and including the data on it (or something like that), I think it will work.

This is what I'm expecting in my code,

   PrintDocument pd = new PrintDocument();
   pd.DocumentName = //get document name of reportviewer.
   pd.Print();

Upvotes: 2

Views: 6555

Answers (1)

Mark
Mark

Reputation: 2926

Looks like it's not simple - but there is an example here on codeproject that might help?

Upvotes: 1

Related Questions