Step 4 - Printing Multiple Controls
- 3 minutes to read
The previous step demonstrated how to customize page settings of printed reports. This topic shows two ways to print several controls at once (using a single report link). The first approach uses a report link of a special type (composition report link), whilst the second approach implies printing container controls. It is assumed that you have successfully completed all the previous steps in this Quick Start guide before reading this topic.
Follow the steps below:
- Add a list box onto the form and fill it with items, as shown in the image below:
- Invoke the link collection editor. Add a report link for the list box control, which was created in the first step of this guide.
- Click the down button displayed adjacent to the Add… button to invoke a dropdown menu and click Add Composition… in this menu to add an empty composition report link to the collection. Alternatively, you can click Add Standard… within the dropdown menu, select the item associated with the TdxCompositionReportLink report class and click OK to close the Add Report window.
- Select the composition link within the list and then click the Show Designer… button. Add a new item to the collection editor invoked and set the item’s ReportLink property to be the report link created for the first list box.
- Add one more item to the collection and set this item’s ReportLink property to be the report link created for the second list box control.
- Close the collection editor and click the Preview… button, the image below shows the result. As you can see, each individual report is printed on an individual page.
- Now let’s consider how multiple controls can be printed on a single page. You can print the list boxes one under another. To accomplish this, select the composition report link and switch its StartEachItemFromNewPage property to False in the Object Inspector.
- To print the list boxes as they appear on a form, add a report link whose source component is the form, as shown below.
- Click the Show Designer… button to invoke the report link’s designer. Switch to the Controls page and uncheck the entries which correspond to button controls so that buttons are not printed. Then click the OK button to close the designer dialog saving the changes made.
- Click the Preview… button to show the form’s print preview. The image below shows the result. As you can see, both list boxes are printed on a single page.