Back to Devexpress

How to: Print a Scheduler Using Reports from a Document Preview Window

wpf-119770-controls-and-libraries-scheduler-examples-how-to-print-a-scheduler-using-reports-from-a-document-preview-window.md

latest6.3 KB
Original Source

How to: Print a Scheduler Using Reports from a Document Preview Window

  • Mar 24, 2025
  • 5 minutes to read

This example illustrates how to create a printable report based on the Scheduler view.

This approach utilizes the Visual Studio Report Designer to create a report containing controls designed to represent Scheduler elements. The report is loaded into the Document Preview window which enables the end-user to print the report or export it to PDF.

This guide consists of the following sections:

Steps 1-3. Add a Scheduler Report to the Application

  1. Open the project that contains the SchedulerControl in the Visual Studio Designer.

  2. In the PROJECT menu, select Add DevExpress Item -> New Item… to invoke the DevExpress Template Gallery dialog. Select the Scheduler Report template.

  3. Click Add Item to generate the code and add the file containing the XtraSchedulerReport class descendant to the project. This automatically invokes the Report Designer for the newly created report.

Note

All references required for Scheduler Reporting are added to the project automatically with the report class from the DevExpress Template Gallery.

Steps 4-6. Load a Report from a Template

Note

To create a report from scratch, skip to Step 7.

  1. To create a report, use one of the templates from the ready-to-use report layout templates. To connect to this gallery at design time within Visual Studio, click the report’s smart tag and select Load Report Template….

  2. In the Report Templates dialog, select the template and click Load. You can use the search box to search for a specific template name.

  3. The selected report is downloaded and opened in the Visual Studio Designer.

Steps 7-15. Create a Report from Scratch

Note

If you have loaded a report from a template in steps 4-6, skip to step 16.

  1. To create a new report, open the Toolbox pane (by pressing Ctrl+Alt+X). Then, select the DayViewTimeCells control in the DX.25.2: Scheduler Reporting tab and drop it onto the report’s DetailBand. Note that this tab is visible only if the XtraSchedulerReport class is opened in the Designer.

  2. Add the HorizontalResourceHeaders control. Place it above the DayViewTimeCells control in the Detail Band.

  3. Add the HorizontalDateHeaders control. Place it above the HorizontalResourceHeaders control.

  4. Use the HorizontalResourceHeaders control’s smart tag menu to link it to the HorizontalDateHeaders control.

  5. Use the DayViewTimeCells control’s smart tag menu to link it to the HorizontalResourceHeaders control, as shown in the image below.

  6. Add the DayViewTimeRuler control, place it on the left side of the DayViewTimeCells control, click its smart tag and select the dayViewTimeCells1 in the DayViewTimeCells drop-down list. The time ruler is linked to the data provider ( ReportDayView ) and anchored to time cells.

  7. Drag the DayViewTimeRuler ‘s top and bottom edges to resize it. Its top border should be aligned to the HorizontalDateHeaders control’s top, and its bottom border to the DayViewTimeCells control’s bottom. The DayViewTimeRuler ‘s visible scale starts at the offset from the top edge, which is specified by the ControlCornersOptions.Top property. To specify the offset in the Visual Studio Designer, click the DayViewTimeRuler ‘s smart tag and set the TopCornerIndent value as shown below:

  8. Add the TimeIntervalInfo control and the CalendarControl to the Detail Band. Place them above the other controls, at the top of the page. The controls automatically bind themselves to the DayViewTimeCells control. Arrange the controls on a page by resizing and moving them. The resulting report is shown below.

  9. Use the Detail band’s smart tag menu to specify that a page break is inserted after the band:

You can save the report layout as a template to reuse it in other applications. For this, click the report’s smart tag, and in the invoked Report Tasks list, select the Save… link.

Steps 16-17. Display the Report

  1. Create a static MyPrintHelper class with the PrintScheduler method, as demonstrated in the code snippet below. Call this method to create a report at runtime, bind it to the Scheduler control and invoke the Preview dialog.

  2. Set the SchedulerControl.CommandBarStyle property to CommandBarStyle.Ribbon to display the integrated ribbon for the WPF Scheduler.

  3. Add the following namespace declarations to the MainWindow.xaml file:

  4. Add a reference to the DevExpress.Xpf.Ribbon.v25.2.dll.

  5. Add a new Print group with a Print Scheduler button to the ribbon, whose associated command calls the MyPrintHelper.PrintScheduler method. This task is accomplished by adding a new InsertAction to the SchedulerControl.RibbonActions collection, as illustrated in the following code:

  6. Run the application, add some appointments and click the Print Scheduler button. The Document Preview window is shown in the image below.