Visual Studio .NET - reportviewer open command in print preview

Asked By David on 02-Apr-12 04:04 PM
Is it possible to put code into a rdlc report  using reportviewer so that it opens the report in print preview mode from a button instead of having to click preview on tool bar when report is open.
I am using Visual Studio 2008


[)ia6l0 iii replied to David on 02-Apr-12 09:19 PM
If it is a web version, you could call the Microsoft.Reporting.WebFormsClient.ReportViewer.invokePrintDialog Method from the client side. 

Add a button :
<input id="ButtonPrintReport" type="button" value="Print Report" onclick="PrintReport();"/>

And add a script like below:
<script language="javascript"> 
         function PrintReport() 
             var reportViewer = $find("ReportViewer1");
                var reportArea = reportViewer.get_reportAreaContentType(); 
                 if (reportArea == Microsoft.Reporting.WebFormsClient.ReportAreaContent.ReportPage) 


Otherwise, you will have to use the CreateStreamCallback function and print the report programmatically without viewing it. Here is a MSDN  walkthrough on this.

Hope this helps.

David replied to [)ia6l0 iii on 03-Apr-12 03:03 PM
HI Dia

Is the code for visual studio 2008?