Occurs when a page is printed or previewed.
Provides data and methods for reporting
Namespace: Dapfor.Net.UiAssembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
public event EventHandler<PrintGridPageEventArgs> PrintPage |
Visual Basic |
---|
Public Event PrintPage As EventHandler(Of PrintGridPageEventArgs) |
Visual C++ |
---|
public: event EventHandler<PrintGridPageEventArgs^>^ PrintPage { void add (EventHandler<PrintGridPageEventArgs^>^ value); void remove (EventHandler<PrintGridPageEventArgs^>^ value); } |
F# |
---|
member PrintPage : IEvent<EventHandler<PrintGridPageEventArgs>, PrintGridPageEventArgs> |
Value
Type: System..::..EventHandler<(Of <(<'PrintGridPageEventArgs>)>)>Remarks
Grid provides standard printing and print preview features via PrintDocument object that enables document printing and previewing.
The example below demonstrates implementation of document preview feature:
Copy | |
---|---|
public void PrintPreview(Grid grid) { PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = grid.PrintDocument; ppd.ShowDialog(grid); } |
The following example demonstrates implementation of content printing feature.
Copy | |
---|---|
public void PrintContent(Grid grid) { PrintDialog pd = new PrintDialog(); pd.Document = grid.PrintDocument; pd.ShowDialog(grid); } |
The grid provides callback feature for print customization. This feature can also be used to customize page headers and footers:
Copy | |
---|---|
grid.PrintPage += delegate(object sender, PrintGridPageEventArgs e) { //Print a page header Rectangle rcHeader = new Rectangle(e.MarginBounds.X, e.PageBounds.Y, e.MarginBounds.Width, e.MarginBounds.Y - e.PageBounds.Y); using(System.Drawing.StringFormat sf = new System.Drawing.StringFormat()) { rcHeader.Inflate(0, -10); sf.LineAlignment = StringAlignment.Far; sf.Alignment = StringAlignment.Center; e.Graphics.DrawString("This is a page header. Print your text here!", SystemFonts.MenuFont, SystemBrushes.GrayText, rcHeader, sf); } //Print a page footer Rectangle rcFooter = new Rectangle(e.MarginBounds.X, e.MarginBounds.Bottom, e.MarginBounds.Width, e.PageBounds.Bottom - e.MarginBounds.Bottom); using (System.Drawing.StringFormat sf = new System.Drawing.StringFormat()) { rcFooter.Inflate(0, -10); sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Center; e.Graphics.DrawString(string.Format("Page {0} of {1}\r\nThis is a page footer. Print your text here!", e.PageNumber, e.PagesCount), SystemFonts.MenuFont, SystemBrushes.GrayText, rcFooter, sf); } } |