Click here to Skip to main content
11,648,785 members (81,162 online)
Click here to Skip to main content

Two simple workarounds for the ReportViewer problems

, 4 Jan 2007 63.2K 1.4K 30
Rate this:
Please Sign up or sign in to vote.
An article on the ReportViewer Problems.


In an application containing the ReportViewer control I have had two following problems :

  1. When the ReportViewer is rendering, trying to close the Parent Form of the ReportViewer may cause to crash the Application.
  2. There is no straight way to copy the report data to the Clipboard.


Rendering problem :

If there are many pages in a report, it takes a few seconds to render. In this case if the user wants to cancel report rendering and closes the Form containing the ReportViewer control, the Application will crash. To solve this problem I used the RenderingBegin and RenderingComplete events of the ReportViewer and the FormClosing event of the Parent Form.

To see how the problem is occurred, consider the included source files. After running the project there are nineteen pages in the report. (32 pages in the print layout mode). By clicking the 'Print Layout' button, the report begins rendering. While the report is rendering, if the user closes the Parent Form, the Application will crash (If we comment added event handlers).

Copy to the Clipboard :

In a report, there is no straight way to copy the report data to the Clipboard. The only way that is available is using the Hyperlink event of the ReportViewer control (There is an related article by Teo Lachev at . To do this, we should set some attributes at the design time :

  • Suppose that there is a 'table' item on the report file. Select each TextBox from the 'Table Details' row.

  • Go to the Properties -> Navigation -> 'Hyperlink action' -> 'Jump to URL'.

  • In the following ComboBox write '= "NoLink:" & Fields!FieldName.Value' . (Replace FieldName with the name of field)

Using the code

For the rendering problem, a variable named IsRendering is defined. In the RenderingBegin we set IsRendering = false. While report is rendering it prevents closing the form by user. The code is as below :

For the copy problem, after setting the required attributes at the design time, we write below code in the reportViewer1_Hyperlink event handler :
<summary>// Copy the report data to the Clipboard.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Afrasiab Cheraghi
Web Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 2 Pin
buyong21-Sep-11 16:54
memberbuyong21-Sep-11 16:54 
GeneralEven after changing to the Hyperlink it don't let you copy to the clipboard Pin
Kaveti24-Aug-07 11:20
memberKaveti24-Aug-07 11:20 
GeneralRe: Even after changing to the Hyperlink it don't let you copy to the clipboard Pin
Afrasiab Cheraghi24-Aug-07 13:51
memberAfrasiab Cheraghi24-Aug-07 13:51 
GeneralRe: Even after changing to the Hyperlink it don't let you copy to the clipboard Pin
Kaveti27-Aug-07 2:47
memberKaveti27-Aug-07 2:47 
GeneralRe: Even after changing to the Hyperlink it don't let you copy to the clipboard Pin
Afrasiab Cheraghi28-Aug-07 7:52
memberAfrasiab Cheraghi28-Aug-07 7:52 
QuestionThe ReportViewer Toolbar Pin
Kschuler25-Jan-07 8:30
memberKschuler25-Jan-07 8:30 
AnswerRe: The ReportViewer Toolbar Pin
Afrasiab Cheraghi26-Jan-07 0:28
memberAfrasiab Cheraghi26-Jan-07 0:28 
QuestionRe: The ReportViewer Toolbar Pin
Kschuler29-Jan-07 8:35
memberKschuler29-Jan-07 8:35 
Thank you very much for your help. Your expertise has been very useful. I've run into another problem with my project that I was hoping you might have the answer to.

I've got windows forms project that uses the ReportViewer in local mode. When I run my report using Visual Studio 2005 everything looks fine. The form pops up and the report loads and it's just the way I want it. However, if I run the .exe outside of Visual Studio this is not the case. The form pops up and the report displays this message "Report processing was cancelled." and a few seconds later the report displays just fine. I do not understand why the error message is displaying and have not been able to find a way to shut it off. Have you heard of or experienced this problem and do you know of a solution or workaround for it? I would appreciate any advice. Thank you.
AnswerRe: The ReportViewer Toolbar Pin
Aeroday19-Jul-07 6:17
memberAeroday19-Jul-07 6:17 
Questionthis is MFC/C++ ? Pin
oleguaua3-Jan-07 19:07
memberoleguaua3-Jan-07 19:07 
AnswerRe: this is MFC/C++ ? Pin
Afrasiab Cheraghi3-Jan-07 21:18
memberAfrasiab Cheraghi3-Jan-07 21:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150804.4 | Last Updated 4 Jan 2007
Article Copyright 2007 by Afrasiab Cheraghi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid