WinForms

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridPrintDocument - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class GridPrintDocument

    Implements printing support for a grid.

    Inheritance
    System.Object
    GridPrintDocument
    GridPrintDocumentAdv
    LayoutSupportHelper
    Namespace: Syncfusion.Windows.Forms.Grid
    Assembly: Syncfusion.Grid.Windows.dll
    Syntax
    public class GridPrintDocument : PrintDocument
    Examples

    Use the following code for printing:

                        GridPrintDocument pd = new GridPrintDocument(grid); //Assumes the default printer
                        if (PrinterSettings.storedPageSettings != null)
                        {
                            pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
                        }
                        PrintDialog dlg = new PrintDialog() ;
                        dlg.Document = pd;
                        dlg.AllowSelection = true;
                        dlg.AllowSomePages = true;
                        DialogResult result = dlg.ShowDialog();
    

    if (result == DialogResult.OK) { pd.Print(); }

    Use the following code for print preview:

                           GridControlBase grid = ActiveGrid;
                        GridPrintDocument pd = new GridPrintDocument(grid, true); //Assumes the default printer
                        if (PrinterSettings.storedPageSettings != null)
                        {
                            pd.DefaultPageSettings = PrinterSettings.storedPageSettings ;
                        }
    

    PrintPreviewDialog dlg = new PrintPreviewDialog() ; dlg.Document = pd; dlg.ShowDialog();

    Constructors

    GridPrintDocument()

    Initializes a new instance of the GridPrintDocument class.

    Declaration
    public GridPrintDocument()

    GridPrintDocument(GridControlBase)

    Initializes a new instance of the GridPrintDocument class for a grid.

    Declaration
    public GridPrintDocument(GridControlBase grid)
    Parameters
    Type Name Description
    GridControlBase grid

    The parent grid for this object.

    GridPrintDocument(GridControlBase, Boolean)

    Initializes a new GridPrintDocument for a grid.

    Declaration
    public GridPrintDocument(GridControlBase grid, bool printPreview)
    Parameters
    Type Name Description
    GridControlBase grid

    The parent grid for this object.

    System.Boolean printPreview

    True if print preview; False if printing.

    Fields

    PageSettingsChanged

    set the bool value for PageSettingsChanged

    Declaration
    protected static bool PageSettingsChanged
    Field Value
    Type Description
    System.Boolean

    Properties

    CustomBounds

    Gets or sets Grid will take this Bounds while calculating page breaks in the OnBeginPrint override. By default it uses PrintDocument's DefaultPageSettings.Bounds.

    Declaration
    protected Rectangle CustomBounds { get; set; }
    Property Value
    Type Description
    System.Drawing.Rectangle

    HelperPageSettings

    Gets or sets the page settings for HelperPageSettings

    Declaration
    public static PageSettings HelperPageSettings { get; set; }
    Property Value
    Type Description
    System.Drawing.Printing.PageSettings

    IsPDFExport

    Gets or sets ToplevelGroupCaption painting in GridGroupingControl.

    Declaration
    protected bool IsPDFExport { get; set; }
    Property Value
    Type Description
    System.Boolean

    IsPrintPreview

    Gets a value indicating whether this object is in print preview mode or if it is output to a printer.

    Declaration
    public bool IsPrintPreview { get; }
    Property Value
    Type Description
    System.Boolean

    PagesToPrint

    Gets or sets the page numbers to print.

    Declaration
    public List<int> PagesToPrint { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.Int32>

    Methods

    OnBeginPrint(PrintEventArgs)

    This fired when start printing.

    Declaration
    protected override void OnBeginPrint(PrintEventArgs ev)
    Parameters
    Type Name Description
    System.Drawing.Printing.PrintEventArgs ev

    The System.Drawing.Printing.PrintEventArgs contains the event data.

    OnEndPrint(PrintEventArgs)

    Raises the System.Drawing.Printing.PrintDocument.EndPrint event. It is called when the last page of the document has printed.

    Declaration
    protected override void OnEndPrint(PrintEventArgs e)
    Parameters
    Type Name Description
    System.Drawing.Printing.PrintEventArgs e

    The System.Drawing.Printing.PrintEventArgsthat contains event data.

    OnPrintPage(PrintPageEventArgs)

    Override the OnPrintPage to provide the printing logic for the document.

    Declaration
    protected override void OnPrintPage(PrintPageEventArgs ev)
    Parameters
    Type Name Description
    System.Drawing.Printing.PrintPageEventArgs ev

    The System.Windows.Drawing.Printing.PrintPageEventArgsthat contains event data.

    Back to top Generated by DocFX
    Copyright © 2001 - 2021 Syncfusion Inc. All Rights Reserved