Applying Report Viewer 2010 Control With RDLC file In Visual Studio 2010 Express Edition (C#)

I use Report Viewer 2010 or version 10 instead of 8 or 9, so that more updated of Report Definition file can be viewed.

First of all, please download Report Viewer 2010 control (Report Viewer Version 10) from this link http://www.microsoft.com/en-us/download/details.aspx?id=6442 and install it since VS 2010 Express was shipped with Report Viewer Version 8 and/or 9.

After you install it, that component will be registered on C:\Windows\assembly folder. If you browse to C:\Windows\assembly using Windows Explorer then you will see custom shell extension view.

Please take note that even though we already install Report Viewer 2010 but VS 2010 Express Edition still not recognized version 10. It still has version 9. We need to copy required library files and add them as project reference.

However, you can not just copy those Assembly’s library with just right click. We need to copy installed 3 library files comes from Report Viewer 10 installation which are Microsoft.ReportViewer.Common,
Microsoft.ReportViewer.ProcessingObjectModel and Microsoft.ReportViewer.Winforms to our own Folder as usual file system.

To do that, you have to copy via command prompt. Please browse to C:\Windows\assembly\GAC_MSIL\Microsoft.ReportViewer.WinForms\10.0.0.0__b03f5f7f11d50a3a. Copy Microsoft.ReportViewer.WinForms.dll to your own folder using xcopy command
Same to do with Microsoft.ReportViewer.Common.dll and Microsoft.ReportViewer.ProcessingObjectModel.dll from their related directories .

As default, VS 2010 Express Edition doesn’t show Report Viewer Control. We need to add it manually to our toolbox list.

  1. First thing first, take a note that your project must have Target Framework of .Net Framework 3.5 or 4, do not use Client Profile.
  2. After that add reference to 3 library files that we already copied before.
  3. Add Report Viewer control to you toolbox list.

  4. ReportViewer control already appear in Toolbox items list

In order to use this Report Viewer control, drag and drop it from Toolbox to a Form. Save your Form, Close and Re-Open your Form.
However, we see that nothing happens in VS 2010 Express. So we need to edit Form’s Designer.cs file. At mine, it is Form1.Designer.cs file. Source code Example:

...
	//add this line to set dock style to Fill
	this.reportViewer1.Dock = System.Windows.Forms.DockStyle.Fill;
			 
       this.reportViewer1.Location = new System.Drawing.Point(0, 0);
       this.reportViewer1.Name = "ReportViewer";
       this.reportViewer1.Size = new System.Drawing.Size(292, 266);
       this.reportViewer1.TabIndex = 0;
			
	//add this line to actually add reportviewer control to Form
	this.Controls.Add(this.reportViewer1);
...

Save it and look back to Form Design View, Report Viewer already appears.

FYI, report viewer is to view a report with extension *.rdlc file. How to make a report itself ? Since we are using Express so we also need free tool to create a report.
I recommend to use SQL Server 2008 R2 Express Edition with Advanced Service. Advanced Service installs tool to create report using SQL Server Reporting Service (SSRS) Visual Studio.

Report file that comes from SSRS Visual Studio is *.rdl, so we have to rename it to *.rdlc for Report Viewer can view it. How to use SSRS Visual Studio is out of scope of this blog post.

Regards,
Agung Gugiaji

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s