Use Report Viewer Control to View SSRS Report in Windows Application

In this article, I will show you how to Use Report Viewer Control to View SSRS Report in Windows Application.

1. First of all open Visual Studio 2010 and go to File-> New-> Project.

1-Use Report Viewer Control to View SSRS Report in Windows Application

2. A New Project window opens. In that window select Visual C# from left pane and select Windows Forms Application as shown in below screenshot.

2-Use Report Viewer Control to View SSRS Report in Windows Application

Then click on OK button.

3. Visual Studio 2010 will add a single form to the project called Form1.cs. Rename that form to ViewerForm.cs.

4. Resize that form to 1024 x 768 dimension.

4-Use Report Viewer Control to View SSRS Report in Windows Application

5. Now add a ReportViewer control named as rptViewer from Reporting controls.

6. Then add a textbox, and name it txtReportURL. Also add a button named btnShowReport and set the button Text property to Show Report. Now your form design looks like below:

6-Use Report Viewer Control to View SSRS Report in Windows Application

7. Now write below code into the click event of Show Report button.

private void btnShowReport_Click(object sender, EventArgs e)
{
    rptViewer.ProcessingMode = ProcessingMode.Remote;
    rptViewer.ServerReport.ReportServerUrl = new Uri(@"http://bhushan-pc/ReportServer2012");
    rptViewer.ServerReport.ReportPath = txtReportURL.Text;
    rptViewer.RefreshReport();
}

7-Use Report Viewer Control to View SSRS Report in Windows Application

8. Now press F5 button. In textbox enter the Path to access the report which is something like below :

/StartSSRS/PersonWithPhoneNumber

9. Then click on Show Report button. You will see result looks like below :

9-Use Report Viewer Control to View SSRS Report in Windows Application

Leave a Reply

Your email address will not be published. Required fields are marked *