Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Insert Images into the Page Header

  • 2 minutes to read

This example demonstrates how to display an image and the report creation time in the right section of the report’s page header.

Link_Images

  1. Create a WinForms application and drop the GridControl control onto the form.

  2. Create PrintingSystem and PrintableComponentLink printing components.

  3. Assign the Grid control to the PrintableComponentLink.Component property and assign the printing system to the created link.

  4. Use the PrintableComponentLink.Images property to add an image to the link’s image collection.

  5. Display this image and the report creation time in the right section of the report’s page header.

using DevExpress.XtraPrinting;
// ...

void InsertImage() {
    // Create a printing system.
    PrintingSystem printingSystem1 = new PrintingSystem();

    //Create a link to print the Grid control.
    PrintableComponentLink printableComponentLink1 = new PrintableComponentLink();

    // Specify the link's printable component.
    printableComponentLink1.Component = gridControl1;

    // Assign the printing system to this link.
    printableComponentLink1.PrintingSystem = printingSystem1;

    // Add an image to the link's image collection.
    printableComponentLink1.Images.Add(Image.FromFile("c:\\dx.png"));

    // Create a PageHeaderArea object.
    PageHeaderArea pgHArea = new PageHeaderArea();

    // Add the image and the report creation time 
    // to the third (rightmost) section of the page header.
    pgHArea.Content.AddRange(new string[] { "", "", "[Time Printed][Image 0]" });

    // Create a PageHeaderFooter object for this link.
    printableComponentLink1.PageHeaderFooter = new PageHeaderFooter(pgHArea, null);

    // Preview the report.
    printableComponentLink1.ShowPreviewDialog();
}
private void Form1_Load(object sender, EventArgs e) {
    InsertImage();
}
//...
See Also