Report with pictures

Top  Previous  Next

The “Picture” object, like many objects in FastReport, can display data from a DB. This object can be connected to a DB field by setting the “DataSet” and “DataField” properties in the object inspector. In contrast to the “Text” object, this is the only way to connect this object to its data.


Let's demonstrate this with a report giving the names and images of some fish. We will again need the “DBDEMOS” database that is included in the Delphi distribution kit.


Create a blank project in Delphi, place a “TTable” component on the form and set some properties:


DatabaseName = 'DBDEMOS'

TableName = 'Biolife.db'


To work with this table in FastReport add a “TfrxDBDataSet” component and set these properties:


DataSet = Table1

UserName = 'Bio'


Finally, add a “TfrxReport” component to the form. Open the report designer and click the “New report” button to create a basic design in FastReport. Now enable the use of the frxDBDataset and its connected table in the report - from the Menu select “Report>Data”, select the “Bio” dataset and click OK.


Now we’ll add objects to the report page. Place a “Text” object containing “Fish” in the “ReportTitle” band. Connect the “Master data” band to the data source (double-click on the band and select “Bio” from the list). Increase the band’s height  to 5 cm by dragging the bottom of the band down or by using the object inspector. Place a “Text” object in the band and connect it to the “CommonName” field using any of the methods previously described. After that, drop the “Picture” object alongside, and connect it to the “Graphic” field by setting its properties in the object inspector:


DataSet = Bio

DataField = 'Graphic'


Note that both of these properties are of the “List” type, and can be set to the required values using the mouse. To make room for the picture, stretch the object to 4 x 2.5cm.




The report design is now finished and it produces the report shown here: