Home Forums WinForms controls Xceed Grid for WinForms How to select the printer and page settings

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17821 |

    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. 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

    ‘ 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#

    // 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.

    Imported from legacy forums. Posted by Xceed admin (had 656 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.