"Hello, World!" report

Top  Previous  Next

In this example we will create a report which, before creating the preview, displays a greeting window using a dialogue form. Create a new project in Delphi and place “TfrxReport” and “TfrxDialogControls” components on the form. Open the FastReport designer by double-clicking on the “TfrxReport” component and add a dialogue form to the report. Place “TfrxLabelControl” and “TfrxButtonControl” objects on the form:

 

_img276

 

Set the object properties:

 

TfrxLabelControl:

Caption = 'Hello, World!'

 

TfrxButtonControl:

Caption = 'OK'

Default = True

ModalResult = mrOk

 

Set the “BorderStyle = bsDialog” property for the form. Both the controls and the form have the same set of properties as for the corresponding Delphi controls.

 

When the dialogue form design is complete return to the report design Page1 tab and place a “Text” object containing the greeting on the page. Preview the report and you will see the dialogue form:

 

_img277

 

After clicking on the OK button the dialogue closes and the report is constructed and displayed. If the dialogue is closed by clicking the system menu “Х” button then the report will not be constructed. FastReport works like this : if there are dialogue forms in a report, the report is only constructed after each dialogue has been closed with ModalResult = mrOk, i.e. in this example by clicking the ОК button,. That is why the “ModalResult” property of the button had to be set to “mrOk.”