FlexGrid for WinForms
PrintDocumentGridRenderer Class
Members  Example 



Represents an object that renders a C1FlexGrid into a paged System.Drawing.Printing.PrintDocument.
Syntax
'Declaration
 
Public Class PrintDocumentGridRenderer 
'Usage
 
Dim instance As PrintDocumentGridRenderer
public class PrintDocumentGridRenderer 
public ref class PrintDocumentGridRenderer 
Remarks

This class may be used to print multiple grids, along with other custom content, into an existing System.Drawing.Printing.PrintDocument object.

To use it, create one PrintDocumentGridRenderer for each grid you want to print. Then handle the document events and call the PrintPage(PrintPageEventArgs) event for the renderers until the value of the CurrentPage property equals PageCount.

The code below renders two grids into a System.Drawing.Printing.PrintDocument: // print two grids into an existing PrintDocument private void button1_Click(object sender, EventArgs e) { using (var dlg = new PrintPreviewDialog()) { dlg.Document = this.printDocument1; dlg.ShowDialog(this); } } // event handlers for the PrintDocument object on the form PrintDocumentGridRenderer _g1, _g2; void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e) { // create and configure grid renderer for the first grid _g1 = new PrintDocumentGridRenderer(c1FlexGrid1); _g1.Options = PrintGridFlags.FitToPageWidth | PrintGridFlags.ExtendLastCol; // create and configure grid renderer for the second grid _g2 = new PrintDocumentGridRenderer(c1FlexGrid2); _g2.Options = PrintGridFlags.FitToPageWidth | PrintGridFlags.ExtendLastCol; } void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { // render first grid if (_g1.CurrentPage < _g1.PageCount) { _g1.PrintPage(e); e.HasMorePages = true; } // render second grid else if (_g2.CurrentPage < _g2.PageCount) { _g2.PrintPage(e); e.HasMorePages = _g2.CurrentPage < _g2.PageCount; } }
Example
The code below renders two grids into a System.Drawing.Printing.PrintDocument:
// print two grids into an existing PrintDocument
private void button1_Click(object sender, EventArgs e)
{
  using (var dlg = new PrintPreviewDialog())
  {
    dlg.Document = this.printDocument1;
    dlg.ShowDialog(this);
  }
}
            
// event handlers for the PrintDocument object on the form
PrintDocumentGridRenderer _g1, _g2;
void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
  // create and configure grid renderer for the first grid
  _g1 = new PrintDocumentGridRenderer(c1FlexGrid1);
  _g1.Options = PrintGridFlags.FitToPageWidth | PrintGridFlags.ExtendLastCol;
  
  // create and configure grid renderer for the second grid
  _g2 = new PrintDocumentGridRenderer(c1FlexGrid2);
  _g2.Options = PrintGridFlags.FitToPageWidth | PrintGridFlags.ExtendLastCol;
}
void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
  // render first grid
  if (_g1.CurrentPage < _g1.PageCount)
  {
    _g1.PrintPage(e);
    e.HasMorePages = true;
  }
  
  // render second grid
  else if (_g2.CurrentPage < _g2.PageCount)
  {
    _g2.PrintPage(e);
    e.HasMorePages = _g2.CurrentPage < _g2.PageCount;
  }
}
Inheritance Hierarchy

System.Object
   C1.Win.C1FlexGrid.PrintDocumentGridRenderer

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PrintDocumentGridRenderer Members
C1.Win.C1FlexGrid Namespace

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Send Feedback