Saturday, October 31, 2015

Create Custom Report Viewer Using the WebBrowser Control in Windows Application





In this article, I will show you how to Create Custom Report Viewer Using the WebBrowser Control in Windows Application.
1. First of all open Visual Studio 2010 and go to File-> New-> Project.
1-Create Custom Report Viewer Using the WebBrowser Control 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 screen shot.
2-Create Custom Report Viewer Using the WebBrowser Control in Windows Application
Then click on OK button.
3. Visual Studio 2010 will add a single form to the project calledForm1.cs. Rename that form to WindowsReportViewer.cs.
4. Resize that form to 1024 x 768 dimension.
4-Create Custom Report Viewer Using the WebBrowser Control in Windows Application
5. Now add a textbox, and name it txtReportURL. Also add a button namedbtnShowReport and set the button Text property to Show Report.
6. Then add WebBrowser control named as WebBrowser from common controls. Now your form design looks like below :
6-Create Custom Report Viewer Using the WebBrowser Control in Windows Application
7. Now write below code into the click event of Show Report button.
?
1
2
3
4
private void btnShowReport_Click(object sender, EventArgs e)
{
    WebBrowser.Navigate(txtReportURL.Text);
}
7-Create Custom Report Viewer Using the WebBrowser Control in Windows Application
8. Now press F5 button. In textbox enter the URL to access the report which is something like below :
http://bhushan-pc/ReportServer2012/Pages/ReportViewer.aspx?%2fStartSSRS%2fPersonAddressDetails&rs:Command=Render 
9. Then click on Show Report button. You will see result like below :
9-Create Custom Report Viewer Using the WebBrowser Control in Windows Application