Using CrystalReportViewer to Display Crystal Reports in .Net - Binding with Code
(Page 3 of 4 )
The following lines of code can be added to the form's load event to bind the Crystal Report to the Viewer.
CrystalReportViewer1.ReportSource = "C:CrystalReportViewerTestCrystalReport1.rpt"
In the above code, "CrystalReportViewer1" is the name of the viewer object, "ReportSource" is the property to be set at run time for the Viewer. "CrystalReportViewerTest" is the name of the Windows application, and "CrystalReport1.rpt" is the name of the report already created in the Windows application.
Binding Crystal Reports at runtime is very beneficial, as we don't have to create forms for each and every Crystal Report in an application. We can simply create one form and bind the required report dynamically when necessary.
Sometimes we have multiple reports in an application, and we need to display a particular report depending upon the user's selection. In such cases, to create Crystal Reports dynamically, we use this type of binding.
Once you have bound your report to the viewer, you should run your application with the start form as the form to which the report is bound. You will see you report, which should look something like this:

You can see a tool bar at the top of the report with different buttons.
Next: Toolbar Functions >>
More .NET Articles
More By Madhuri Chanda