ComponentOne FlexReport for WinForms
Modifying the Fields
Working with FlexReport > Modifying the Fields

You are not restricted to using VBScript to evaluate expressions in calculated fields. You can also specify scripts that are triggered when the report is rendered, and you can use those to change the formatting of the report.These scripts are contained in event properties. An event property is similar to a Visual Basic event handler, except that the scripts are executed in the scope of the report rather than in the scope of the application that is displaying the report.

For example, you can use an event property to set a field's Font and ForeColor properties depending on its value. This behavior would then be a part of the report itself, and would be preserved regardless of the application used to render it.

Of course, traditional events are also available, and you should use them to implement behavior that affects the application rather than the report. For example, you could write a handler for the StartPage event to update a page count in your application, regardless of which particular report is being rendered.

The following table lists the event properties that are available and typical uses for them:

Object Property Description
C1FlexReport OnOpen Fired when the report starts rendering. Can be used to modify the ConnectionString or RecordSource properties, or to initialize VBScript variables.
OnClose Fired when the report finishes rendering. Can be used to perform clean-up tasks.
OnNoData Fired when a report starts rendering but the source recordset is empty. You can set the Cancel property to True to prevent the report from being generated. You could also show a dialog box to alert the user as to the reason why no report is being displayed.
OnPage Fired when a new page starts. Can be used to set the Visible property of sections of fields depending on a set of conditions. The control maintains a Page variable that is incremented automatically when a new page starts.
OnError Fired when an error occurs.
Section OnFormat Fired before the fields in a section are evaluated. At this point, the fields in the source recordset reflect the values that will be rendered, but the report fields do not.
OnPrint Fired before the fields in a section are printed. At this point, the fields have already been evaluated and you can do conditional formatting.

The following topics illustrate typical uses for these properties.

See Also