Xceed Grid for WinForms v4.3 Documentation
How to select the printer and page settings

Welcome to Xceed Grid for WinForms v4.3 > Task-Based Help > Printing > How to select the printer and page settings

In order to allow you users to select the printer and page settings you must use the PageSetupDialog component provided by Microsoft and create a new instance of the GridPrintDocument class.

Demonstration

The following example demonstrates how to allow your users to select the printer and page settings when printing the grid. It assumes that you have a PageSetupDialog component on your form.

VB.NET Copy Code

' Allow the user to select the page settings and the printer
Dim oPrintDoc As New Xceed.Grid.GridPrintDocument(GridControl1) 

PageSetupDialog1.PageSettings = oPrintDoc.DefaultPageSettings 

If PageSetupDialog1.ShowDialog() = DialogResult.OK Then
    oPrintDoc.DefaultPageSettings = PageSetupDialog1.PageSettings 

    Dim x As New PrintDialog()
    x.Document = PageSetupDialog1.Document 

    If x.ShowDialog() = DialogResult.OK Then
         oPrintDoc.PrinterSettings = x.PrinterSettings
         oPrintDoc.Print()
    End If
End If 

C# Copy Code

// Allow the user to select the page settings and the printer
Xceed.Grid.GridPrintDocument oPrintDoc = new Xceed.Grid.GridPrintDocument( gridControl1 ); 

pageSetupDialog1.PageSettings = oPrintDoc.DefaultPageSettings; 

if( pageSetupDialog1.ShowDialog() == DialogResult.OK )
{
  oPrintDoc.DefaultPageSettings = PageSetupDialog1.PageSettings;

  PrintDialog x = new PrintDialog();
  x.Document = pageSetupDialog1.Document;

  if( x.ShowDialog() == DialogResult.OK )
  {
    oPrintDoc.PrinterSettings = x.PrinterSettings;
    oPrintDoc.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.