Answered by:
Display Report Viewer Report in Print Layout Mode

Question
-
Hello,
I have several reports that are generated from the report viewer control in Windows form application. The reports work good and ultimately display the data as I want to see it.
I want to assist the user in printing the reports quicker. To do so, I would like to eliminate the step where the user would have to click the "Print Layout" button in the report viewer toolbar.
As I understand it, this button has a toggle value somewhere. I just don't know how to access it. I would imagine that once I know the appropriate name/location of that particular button, I can set the toggle to True or On or whatever after the refresh method and before calling the show method for the report.
Any ideas on how to accomlish this?
Thanks.Sunday, February 4, 2007 9:24 PM
Answers
-
Hi Tom,
Looking at your code I assume you are setting the display mode in the initialize. Try putting it in the OnLoad event handler.
Remco
Friday, February 9, 2007 9:09 AM
All replies
-
LTD,
According to your question, I suggest you to access this toogle value from the IReportViewerMessages interface. Actuallly there are so many public properties that allow applications to provide customized user interfafce maeeages. Such as PrintButtonTooltip, PageSetupButtonToolTip properties. Please take a look at the following link that shows the related properties:
Tuesday, February 6, 2007 5:16 AM -
Hi,
Try this:
reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);Regards,
Remco
- Proposed as answer by David García Alonso Monday, May 2, 2011 3:22 PM
Thursday, February 8, 2007 9:41 AM -
Remco,
That sounds like it would work for me. However, I am getting the following error message when I run the code.
It is a System.InvalidOperationException and the detail states "{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}" The error message dialog box also states "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."
Here is the subroutine:
Public
Sub ShowReport(ByVal reportName As String) ' Select Report ' Initialize the report viewerReportViewer1.LocalReport.ReportEmbeddedResource =
"Coordinator_Software." & reportName ' Fill data Try ' This is read-only data, so don't need to enforce constraints ' As a result, we do not need to load the related tables. Me.Coordinator_Test_DatabaseDataSet.EnforceConstraints = False Me.Orders_by_ParentTableAdapter.Fill(Me.Coordinator_Test_DatabaseDataSet.Orders_by_Parent) Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout) Me.ReportViewer1.RefreshReport() Me.ShowDialog() Catch ex As ExceptionMessageBox.Show(ex.Message,
"Report Preview", MessageBoxButtons.OK, MessageBoxIcon.Stop) End Try End SubI have tried placing the Display Mode line in various locations, but I always get the error. Any help in troubleshooting this error would be appreciated.
Thanks, Tom
Friday, February 9, 2007 12:58 AM -
Hi Tom,
Looking at your code I assume you are setting the display mode in the initialize. Try putting it in the OnLoad event handler.
Remco
Friday, February 9, 2007 9:09 AM