xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-921e6d6b.md
Occurs after an XRControl object is displayed in the report.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public virtual event EventHandler AfterPrint
Public Overridable Event AfterPrint As EventHandler
The AfterPrint event's data class is EventArgs.
You can handle the following events to access and customize a report control:
The AfterPrint event is raised when a control is already printed on a particular page in a report.
The following code snippet demonstrates how to use the AfterPrint event to extend a report with another report’s pages.
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System;
using System.Drawing;
// ...
XtraReport CreateReport() {
XtraReport1 report1 = new XtraReport1();
report1.AfterPrint += Report1_AfterPrint;
return report1;
}
void Report1_AfterPrint(object sender, EventArgs e) {
XtraReport2 report2 = new XtraReport2();
report2.CreateDocument();
XtraReport report1 = (XtraReport)sender;
report1.ModifyDocument(x => x.AddPages(report2.Pages));
}
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
Imports System
Imports System.Drawing
' ...
Private Function CreateReport() As XtraReport
Dim report1 As New XtraReport1()
AddHandler report1.AfterPrint, AddressOf Report1_AfterPrint
Return report1
End Function
Private Sub Report1_AfterPrint(ByVal sender As Object, ByVal e As EventArgs)
Dim report2 As New XtraReport2()
report2.CreateDocument()
Dim report1 As XtraReport = DirectCast(sender, XtraReport)
report1.ModifyDocument(Sub(x)
x.AddPages(report2.Pages)
End Sub)
End Sub
You can also handle a report’s AfterPrint event. The following code snippet demonstrates how to use the AfterPrint event to add a brick to a report’s page.
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System;
using System.Drawing;
// ...
XtraReport CreateReport() {
XtraReport report = new XtraReport();
report.AfterPrint += Report_AfterPrint;
return report;
}
void Report_AfterPrint(object sender, EventArgs e) {
XtraReport report = (XtraReport)sender;
report.Pages[0].AddBrick(CreateVerticalLabel());
}
LabelBrick CreateVerticalLabel() {
LabelBrick labelBrick = new LabelBrick() {
Angle = 90,
Text = "This is a label with vertical text",
Location = new PointF(100, 300),
Size = new SizeF(100, 2700),
};
return labelBrick;
}
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
Imports System
Imports System.Drawing
' ...
Private Function CreateReport() As XtraReport
Dim report As New XtraReport()
AddHandler report.AfterPrint, AddressOf Report_AfterPrint
Return report
End Function
Private Sub Report_AfterPrint(ByVal sender As Object, ByVal e As EventArgs)
Dim report As XtraReport = DirectCast(sender, XtraReport)
report.Pages(0).AddBrick(CreateVerticalLabel())
End Sub
Private Function CreateVerticalLabel() As LabelBrick
Dim labelBrick As New LabelBrick() With {
.Angle = 90,
.Text = "This is a label with vertical text",
.Location = New PointF(100, 300),
.Size = New SizeF(100, 2700)}
Return labelBrick
End Function
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AfterPrint event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-dashboard-pivot-custom-export/CS/WinformsExport/Form1.cs#L31
pivot1.CustomFieldValueCells += PivotCustomFieldValueCells;
pivot1.AfterPrint += PivotAfterPrint;
}
winforms-dashboard-pivot-custom-export/VB/WinFormsExport/Form1.vb#L33
AddHandler pivot1.CustomFieldValueCells, AddressOf PivotCustomFieldValueCells
AddHandler pivot1.AfterPrint, AddressOf PivotAfterPrint
End If
See Also