New to Telerik Reporting? Download free 30-day trial

Using event handlers in the Standalone Report Designer

The Standalone Report Designer and Standalone Report Designer for .NET support attaching compiled code event handlers for the ItemDataBinding, ItemDataBound, and NeedDataSource report events. This article describes how you can add handlers for these events to reports created with the Standalone Report Designer, as well as how you can use existing handlers from programmatic report definitions that have been imported into the Standalone Report Designer.

Add event handlers to reports created with the Standalone Report Designer

Provided you have a report created with the Standalone Report Designer, the steps below will show you how to handle one of its events. For demonstration purposes, let's assume the report is named "CityReport" and you wish to handle its NeedDataSource event:

  1. Create a new empty class library and choose a target framework that is compatible with your version of the Standalone Report Designer. The .NET Standard 2.0 target framework should work in both versions of the designer.
  2. Add the Telerik.Reporting NuGet package to the project.
  3. Create a new class that inherits the Telerik.Reporting.Report class and ensure its name matches the (Name) property of your report.
  4. Add a handler method for the NeedDataSource event.

    namespace ClassLibrary
    {
        public class CityReport : Telerik.Reporting.Report
        {
            private void CityReport_NeedDataSource(object sender, System.EventArgs e)
            {
                Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
                processingReport.DataSource = new string[] { "Sofia", "London", "Tokyo" };
            }
        }
    }
    
  5. Build the project, copy the generated assembly from the bin folder to the installation directory of the Standalone Report Designer, and extend the configuration of the designer using the steps listed in the Extending Report Designer article.

  6. Open the "CityReport" report with the Standalone Report Designer and set its NeedDataSource property to the name of the method created in the previous steps - "CityReport_NeedDataSource".
  7. Preview the report.

Use event handlers from imported programmatic report definitions in the Standalone Report Designer

Assuming you have a programmatic report definition created with the Visual Studio Report Designer that handles one of the supported events, use the following approach to run the report in the Standalone Report Designer.

  1. Copy the assembly containing the programmatic report definition to the installation directory of the Standalone Report Designer as well as any other assemblies it depends on and extend the configuration of the designer using the steps listed in the Extending Report Designer documentation article.
  2. Import the programmatic report from its container assembly by following the instructions in the Importing Type Report Definitions documentation article.
  3. Preview the report and the code of the event handlers should be executed.
In this article