By default, the grid is not printed with page numbers. In order to include page numbers when printing, you will need to create a class that derives from the GridPrintDocument class and override the OnPrintPage method (to be able to custom print the header or footer in this case, or other items if desired).
Demonstration
The following example demonstrates the minimumimplementation required in order to print page numbers when printing the grid.
VB.NET
Copy Code
Imports Xceed.Grid
Public Class CustomGridPrintDocument Inherits GridPrintDocument
Private m_grid As GridControl
Public Sub New(ByVal grid As GridControl) MyBase.New(grid) m_grid = grid End Sub
Protected Overrides Sub OnPrintPage(ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim gc As GraphicsContainer = e.Graphics.BeginContainer()
Try MyBase.OnPrintPage( e ) Finally e.Graphics.EndContainer(gc) End Try
' Print added text boxes (header and footers) If Not e.Cancel And Me.IsCurrentPrintingPageSelected Then Dim brush As New System.Drawing.SolidBrush(Color.Black)
e.Graphics.DrawString("Page number " + _ Me.CurrentPageNumber.ToString(), m_grid.Font, brush, _ New RectangleF(e.MarginBounds.X, e.MarginBounds.Y - 20, _ e.MarginBounds.Width, e.MarginBounds.Height))
brush.Dispose() End If End Sub
End Class
C#
Copy Code
using Xceed.Grid;
public class CustomGridPrintDocument : GridPrintDocument { private GridControl m_grid;