Assign report to the viewer in design time
To use Telerik Reports in Windows Forms application, you need the Windows Forms report viewer:
- Drag the ReportViewer control from the Toolbox
to the form design surface.
- Add reference to the class library that contains your reports in the windows form application.
- Build the application
- Set the ReportSource for the report viewer. For more information, see How to: Set ReportSource for Report Viewers.
- To run the report in the viewer, call ReportViewer.RefreshReport() from your application code.
Assign report to the viewer programatically
In the Form_Load event handler you create an instance report source and set its ReportDocument
property to a report instance. Next assign the instance report source to the ReportSource property of the viewer.
Finally call ReportViewer.RefreshReport().
private void Form1_Load(object sender, EventArgs e)
var typeReportSource = new Telerik.Reporting.TypeReportSource();
typeReportSource.TypeName = "Telerik.Reporting.Examples.CSharp.ListBoundReport, CSharp.ReportLibrary";
this.reportViewer1.ReportSource = typeReportSource;
this.reportViewer1.RenderingBegin += reportViewer1_RenderingBegin;
this.reportViewer1.RenderingEnd += reportViewer1_RenderingEnd;
this.reportViewer1.PrintBegin += reportViewer1_PrintBegin;
this.reportViewer1.PrintEnd += reportViewer1_PrintEnd;
this.reportViewer1.ExportBegin += reportViewer1_ExportBegin;
this.reportViewer1.ExportEnd += reportViewer1_ExportEnd;
this.reportViewer1.UpdateUI += reportViewer1_UpdateUI;
this.reportViewer1.Error += reportViewer1_Error;
Private Sub Form1_Load(sender As Object, e As EventArgs)
Dim typeReportSource = New Telerik.Reporting.TypeReportSource()
typeReportSource.TypeName = "Telerik.Reporting.Examples.CSharp.ListBoundReport, CSharp.ReportLibrary"
Me.ReportViewer1.ReportSource = typeReportSource
AddHandler Me.ReportViewer1.RenderingBegin, AddressOf reportViewer1_RenderingBegin
AddHandler Me.ReportViewer1.RenderingEnd, AddressOf reportViewer1_RenderingEnd
AddHandler Me.ReportViewer1.PrintBegin, AddressOf reportViewer1_PrintBegin
AddHandler Me.ReportViewer1.PrintEnd, AddressOf reportViewer1_PrintEnd
AddHandler Me.ReportViewer1.ExportBegin, AddressOf reportViewer1_ExportBegin
AddHandler Me.ReportViewer1.ExportEnd, AddressOf reportViewer1_ExportEnd
AddHandler Me.ReportViewer1.UpdateUI, AddressOf reportViewer1_UpdateUI
AddHandler Me.ReportViewer1.[Error], AddressOf reportViewer1_Error