Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Either can't Print or Invoke error - Catch 22

Status
Not open for further replies.

BobWman

Programmer
Jan 7, 2002
169
US
I am using Visual Studio 2005 and SQL Reporting Services 2005 with a Local Report. I have a viewer on a WinForm.
For small reports, less than 1 page, I experienced a problem where I couldn't print a report after it was displayed on the screen unless I went into Page Setup or Print Layout first. If I clicked the Printer icon and tried to print - no error occurred, but nothing printed. This problem was fixed by adding the following line:

Me.Viewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)

Putting this line of code in either the Form_Load or Viewer_RenderingComplete event fixes the problem for small reports. However, it causes problems for larger reports. The reports are rendered very slowly. It takes about 20 seconds to completely render a 40 page report. If you close the viewer before the report completely renders, you get the following error message - and the program crashes (you can't prevent it with exception handling).

"Invoke or BeginInvoke cannot be called on a control until the window handle has been created"

Now, if you remove the SetDisplayMode method, large reports render quickly and they will print OK. They don't seem to have the same problem as small reports.

Thus, I have a catch 22. SetDisplayMode seems to be required for small reports, but causes a problem with larger reports.

Does anyone have a fix or suggestion?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top