Handling Report Events

One of the methods for expanding reports functionality is handling events occurred when the user works with a report.

An event handler enables the user to execute a specified operation each time the event occurs. For example, on connecting an event handling unit, the following options become available:

Regular reports enable the user to set up handling of the events that occur:

Main purpose of connection of application macros and event handlers:

Signature of the specified macro can contain parameters.

Working with Event Handling Units

To work with event handling units, execute one of the operations:

After executing one of the operations the List of Units side panel opens:

Select the existing event handling unit or create a new one.

Connect existing unit

Create a unit

Create an event handler

Reset event handler

Open unit in development environment

Remove unit from list

Besides events handling, a unit can implement custom functions to transform data. If the list of units contains such a unit, custom functions will be available in the function wizard on creating a formula.

Example of Event Handler

To execute the example, create a unit. Add links to the Drawing, Express, Report, and Tab system assemblies.

Sub Main;
Begin
    
End Sub Main;

Class EventsClass: ReportEvents
...
    // Event that occurs after regular report sheet calculation
    Public Sub OnAfterRecalcSheet(Sheet: IPrxSheet);
    Var
        Tab: ITabSheet;
        Range: ITabRange;
        Style: ITabCellStyle;
    Begin
        // Get report sheet table
        Tab := Sheet As ITabSheet;
        // Select cell range for highlightin
        Range := Tab.Cells(00105);
        // Set formatting style for selected range
        Style := Range.Style;
        // Set cell background fill for selected range with green color
        Style.BackgroundBrush := New GxSolidBrush.Create(GxColor.FromName("Green"));
    End Sub OnAfterRecalcSheet;
...
End Class EventsClass;

As a result, when the event occurs that follows regular report sheet calculation, background of the A0:F10 cell range is filled with green color.

See also:

Building Report