Telerik Reporting

Assign report to the viewer in design time

To use Telerik Reports in Windows Forms application, you need the Windows Forms report viewer:

  1. Drag the ReportViewer control from the Toolbox to the form design surface.

  2. Add reference to the class library that contains your reports in the windows form application.
  3. Build the application
  4. Set the Report property of the viewer using the drop down list in the Properties Window.
  5. 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 a report instance. If the Report DataSource property changes or hasn't been assigned in the designer, assign the data source after instantiating the report object. Next assign the report object to the ReportViewer Report property. Finally call ReportViewer.RefreshReport().

CopyC#
private void Form1_Load(object sender, System.EventArgs e)
{
        Report1 report1 = new Report1(); 
        //report1.DataSource = MyDataSource; 
        this.ReportViewer1.Report = report1;
        this.ReportViewer1.RefreshReport();
}
CopyVB.NET
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim report1 As New Report1()
        'report1.DataSource = MyDataSource; 
        Me.ReportViewer1.Report = report1
        Me.ReportViewer1.RefreshReport()
End Sub

See Also