Back to Devexpress

GridView.AfterPrintRow Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-4c24ac6f.md

latest4.6 KB
Original Source

GridView.AfterPrintRow Event

Fires after an individual row has been printed/exported, and allows you to add custom information to the printout/export output.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Printing")]
public event AfterPrintRowEventHandler AfterPrintRow
vb
<DXCategory("Printing")>
Public Event AfterPrintRow As AfterPrintRowEventHandler

Event Data

The AfterPrintRow event's data class is PrintRowEventArgs. The following properties provide information specific to this event:

PropertyDescription
BrickGraphicsGets a BrickGraphics object that implements report drawing functions.
GraphicsGets a GDI+ grid’s drawing surface.
HasFooterGets whether the row contains a footer.
LevelGets the group level of the printed row .
PSGets the PrintingSystem object that provides methods to create bricks in the printout/export output.
RowHandleGets the handle of the printed row.
XGets or sets the X coordinate, in pixels, where the next row will be drawn in the printout/export output.
YGets or sets the Y coordinate, in pixels, where the next row will be drawn in the printout/export output.

Remarks

The AfterPrintRow event fires after an individual row has been printed/exported. You can handle this event to customize the printout (export output). For instance, you can insert page breaks, add custom information to the output, etc.

When adding custom information to the output, you typically draw it at the position specified by the PrintRowEventArgs.X and PrintRowEventArgs.Y properties. After drawing, you need to adjust these coordinates, so that the next row is printed/exported after it has been drawn.

To perform actions before a row is printed/exported, handle the GridView.BeforePrintRow event. See this topic for an example of customizing the print/export output. The techniques demonstrated by this example are also applicable when handling the AfterPrintRow event.

Example

This example handles the AfterPrintRow event to print group rows with footers on separate pages.

csharp
private void gridView1_AfterPrintRow(object sender, Views.Printing.PrintRowEventArgs e) {
    if(e.HasFooter)
        e.PS.InsertPageBreak(e.Y);
}
vb
Private Sub gridView1_AfterPrintRow(ByVal sender As Object, ByVal e As Views.Printing.PrintRowEventArgs)
    If e.HasFooter Then
        e.PS.InsertPageBreak(e.Y)
    End If
End Sub

See Also

BeforePrintRow

Export Overview

Printing Overview

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace