Skip to main content
A newer version of this page is available. .

How to: Use Link Events (Introduction)

  • 3 minutes to read

This topic contains information related to dynamic report creation. The XtraPrinting Library provides events that occur on report creation, which you can handle and implement through your own logic. So, it is possible to print out any information you want.

The XtraPrinting Library also gives you the ability to create reports for custom controls. These reports are static. For example, if you need to create reports for controls of a specific class, then it is best to apply this method. Here, you have to implement the IPrintable interface for this class.

Every report consists of several areas: Marginal Header, Marginal Footer, Inner Page Header, Inner Page Footer, Report Header, Detail Header, Detail, Detail Footer, Report Footer. The following image demonstrates what report regions these areas occupy.

Report Structure

You can refer to the Document Sections topic to learn more about a report’s structure.

The XtraPrinting Library provides events which occur when creating the report areas detailed above. You can access them via a link (the Link class or its descendants). They are:

When a link is constructing a report, it generates the events listed above in this exact order. So, you are able to handle these events to render a printed report.

To do this, you have to create a link object within the PrintingSystem.Links collection. For instance, at design time this task can be performed with the help of the Link Collection Editor for the PrintingSystem component. To add a link to the collection, click the Add button, and choose the link type from the list. Assume we want to create a report for a Link instance.

LinkCollectionEditor1

Click the Events button Events button to display the link object’s events. Double-click those events you want to handle. After closing the window, the declaration of the chosen events will be added to the code.

LinkCollectionEditorEvents

The following code lists empty LinkBase.CreateDetailHeaderArea and LinkBase.CreateDetailArea event handlers added to a class:


using DevExpress.XtraPrinting;
// ...

    private void link1_CreateDetailHeaderArea(object sender, CreateAreaEventArgs e) {
        // Place your code here.
    }

    private void link1_CreateDetailArea(object sender, CreateAreaEventArgs e) {
        // Place your code here.
    } 

The CreateAreaEventArgs class describes data passed to event handlers. The CreateAreaEventArgs.Graph property specifies the BrickGraphics surface on which to create report elements (bricks). The sender of events is a link itself. So, you can cast this object to the corresponding Link class to access the required properties and methods.

Note

The following tutorial demonstrates a complete example of report creation with the help of events: How to: Use Link Events (Complete Sample).