Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Collapse]Scheduler
   [Expand]Getting Started
   [Expand]Appointments
    Resources
    Reminders
   [Expand]Views
   [Expand]Visual Elements
   [Expand]Styles and Templates
   [Expand]Design-Time Features
    Time Zones
   [Expand]Data Binding
    Grouping
    Selecting
    Navigating
    Printing
    End-User Restrictions
   [Collapse]Examples
    [Expand]How to: Create Recurrence in Code
     How to: Display the Integrated Ribbon for the Scheduler
     How to: Create the Scheduler with the DateNavigator
     How to: Bind Scheduler to Data using the Entity Framework Code First Approach
     How to: Customize Editing and Recurrence Dialogs
     How to: Customize the In-Place Editor
     How to: Create Custom Labels and Statuses
     How to: Customize Appointment Appearance
     How to: Determine what Scheduler Element Is Hovered by the Mouse Pointer
     How to: Set Default Values for a New Appointment
     How to: Print a Scheduler Using Reports from a Document Preview Window
    Migration Guidelines
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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

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:

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

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

Expanded 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.18.1: 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.

    Note

    The current implementation requires that report controls are in the DetailBand only .

  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.

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

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T581109.

    This code snippet contains the PrintScheduler method which performs the following tasks:
    • Instantiate the XtraSchedulerReport descendant. The class can be designed in Visual Studio or loaded from a template.
    • Specify the time interval of the report's scheduler data.
    • Connect the SchedulerPrintAdapter to the report instance.
    • Call the PrintHelper.ShowPrintPreview method to create a document and display it using the built-in document preview window.

  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.v18.1.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:

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T581109.

    Show Me

    A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T581109.

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

Is this topic helpful?​​​​​​​