Back to Devexpress

How to: Print a Scheduler and Show its Print Preview

windowsforms-2270-controls-and-libraries-scheduler-examples-printing-and-reporting-how-to-print-a-scheduler-and-show-its-print-preview.md

latest2.8 KB
Original Source

How to: Print a Scheduler and Show its Print Preview

  • Nov 13, 2018
  • 2 minutes to read

This example demonstrates the built-in print functionality of the SchedulerControl. To print the SchedulerControl, use either the SchedulerControl.Print or SchedulerControl.ShowPrintPreview methods.

Note

The SchedulerControl can be printed and previewed only if the XtraPrinting Library is available. To verify that printing the scheduler is possible, use the SchedulerControl.IsPrintingAvailable property.

To modify print settings, use the SchedulerControl.OptionsPrint property. End-users can specify printer settings in the Page Setup Dialog invoked by calling the SchedulerControl.ShowPrintOptionsForm method.

csharp
using DevExpress.XtraScheduler;
// ...

private void ShowSchedulerPreview(SchedulerControl scheduler) {
    // Check whether the SchedulerControl can be previewed.
    if(!scheduler.IsPrintingAvailable) {
        MessageBox.Show("The 'DevExpress.XtraPrinting.vX.Y.dll' is not found", "Error");
        return;
    }

    // Open the Preview window.
    scheduler.ShowPrintPreview();
}

private void PrintScheduler(SchedulerControl scheduler) {
    // Check whether the SchedulerControl can be printed.
    if(!scheduler.IsPrintingAvailable) {
        MessageBox.Show("The 'DevExpress.XtraPrinting.vX.Y.dll' is not found", "Error");
        return;
    }

    // Print.
    scheduler.Print();
}
vb
Imports DevExpress.XtraScheduler
' ...

Sub ShowSchedulerPreview(ByVal scheduler As SchedulerControl)
   ' Check whether the SchedulerControl can be previewed.
   If Not scheduler.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting.vX.Y.dll' is not found", "Error")
      Return
   End If

   ' Opens the Preview window.
   scheduler.ShowPrintPreview()
End Sub

Sub PrintScheduler(ByVal scheduler As SchedulerControl)
   ' Check whether the SchedulerControl can be printed.
   If Not scheduler.IsPrintingAvailable Then
      MessageBox.Show("The 'DevExpress.XtraPrinting.vX.Y.dll' is not found", "Error")
      Return
   End If

   ' Print.
   scheduler.Print()
End Sub

The image below shows the print preview of a SchedulerControl.