Xceed Grid for WinForms v4.3 Documentation
Welcome to Xceed Grid for WinForms v4.3 / Task-Based Help / Printing / How to print a range of pages

In This Topic
    How to print a range of pages
    In This Topic

    If you use the grid's Print method, the entire grid will be printed unless you create a GridPrintDocument object, set its properties and call its Print method instead. By setting the GridPrintDocument's PrinterSettings.FromPage and .ToPage to define the range of pages to print. If you want to decide on a page-by-page basis, you must handle the QueryPrintPage event where you can set the IsPageSelected boolean to decide if that page should be printed.

    Demonstration (range of pages)

    The following code demonstrates how to print pages 2 through 5:

    VB.NET Copy Code
    Dim printDocument As New GridPrintDocument(GridControl1)

    printDocument.PrinterSettings.PrintRange = Drawing.Printing.PrintRange.SomePages
    printDocument.PrinterSettings.FromPage = 2
    printDocument.PrinterSettings.ToPage = 5

    printDocument.Print()                       
    C# Copy Code

    GridPrintDocument printDocument = New GridPrintDocument(GridControl1); 

    printDocument.PrinterSettings.PrintRange = Drawing.Printing.PrintRange.SomePages;
    printDocument.PrinterSettings.FromPage = 2;
    printDocument.PrinterSettings.ToPage = 5; 

    printDocument.Print();

    Keep in mind that if you call the grid's Print or PrintPreview methods, the grid will always be printed with the default print document.