windowsforms-3435-controls-and-libraries-printing-exporting-examples-page-header-and-footer-how-to-insert-images-into-the-page-header.md
This example demonstrates how to display an image and the report creation time in the right section of the report’s page header.
Create a WinForms application and drop the GridControl control onto the form.
Create PrintingSystem and PrintableComponentLink printing components.
Assign the Grid control to the PrintableComponentLink.Component property and assign the printing system to the created link.
Use the PrintableComponentLink.Images property to add an image to the link’s image collection.
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();
}
//...
Imports DevExpress.XtraPrinting
' ...
Private Sub InsertImage()
' Create a printing system.
Dim printingSystem1 As New PrintingSystem()
'Create a link to print the Grid control.
Dim printableComponentLink1 As 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.
Dim pgHArea As 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, Nothing)
' Preview the report.
printableComponentLink1.ShowPreviewDialog()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
InsertImage()
End Sub
' ...
See Also