devexpress gridcontrol print code example

Example 1: landscape print gridcontrol devexpress

private void gridView1_PrintInitialize(object sender, DevExpress.XtraGrid.Views.Base.PrintInitializeEventArgs e)
 {
   PrintingSystemBase pb = e.PrintingSystem as PrintingSystemBase;
   pb.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Legal;
   pb.PageSettings.Landscape = true;
 }

 private void preview(GridControl grid)
 {   
   if (!grid.IsPrintingAvailable)
   {
     MessageBox.Show("The 'XtraPrinting' library is not found", "Error");
     return;
   }
  grid.ShowRibbonPrintPreview();
 }

private void btnPrint_Click(object sender, EventArgs e)
{
	preview(dtMembers);
}

Example 2: print gridcontrol devexpress

gridProperties.ShowRibbonPrintPreview();