Previewing v2009 vol 1: Printing appointments from the WinForms scheduler

19 February 2009

We locked the scheduler team and the reporting team in the same broom closet for a little while this release cycle to come up with a great reporting solution for all those WinForms applications that use the scheduler. And just before they keeled over from the lack of oxygen, they came up with an excellent addition to XtraScheduler that will allow you to produce professional diaries and PIM-style reports from your appointments. This new functionality is only available if you have both XtraScheduler and XtraReports (say, as part of DXperience Enterprise) since it makes use of features from both. Let's take a look.

First of all, one of the teams' main goals was to maintain as much flexibility as possible. This wasn't to be a "print screen" type solution, but a solution that should be designed. Hence the need for XtraReports: the new XtraScheduler Suite in v2009 vol 1 has a new control that descends from the XtraReport class called XtraSchedulerReport. This has the normal banded report designer that you're used to from XtraReports, and there are a set of new report controls that you can drop onto the designer surface to build up a scheduler report.

The report gets its data through a print adapter. The main purpose of this adapter object is to compose a data set that will be used in the report. We provide two print adapters: the SchedulerStoragePrintAdapter and SchedulerControlPrintAdapter. Since the print adapters provide a set of validation events, you can easily filter the scheduler data to suit the report. As an example, you could handle the SchedulerPrintAdapter.ValidateAppointments event in order to print appointments which meet some specific criteria.

The next layer is the report view. This is much like the view which exists in the XtraScheduler control, so there are ReportDayView, ReportWeekView, ReportTimelineView components.

Finally, as stated above, the report itself is a container for report bands, and each band has a set of controls placed inside them. We provide two distinct sets of controls.
The first, and most important set consists of controls that represent time cells with appointments. They are: DayViewTimeCells, HorizontalWeek, FullWeek, and TimelineCells. The second set of controls, the auxiliary controls if you like, include:

  • headers - the HorizontalResourceHeaders, VerticalResourceHeaders, HorizontalDateHeaders, DayOfWeekHeaders, and TimelineScaleHeaders.
  • calendar - the CalendarControl control
  • time ruler - the DayViewTimeRuler control
  • information - controls used to display miscellaneous information, such as the TimeIntervalInfo and ResourceInfo controls

They are similar to the XtraReport controls you know now (in that they're only there to drop on the report designer surface, you can't use them elsewhere), although they have their own peculiarities.

Since all that was a bit abstract, let's see how easy it is to create a professionally designed scheduler report.

  1. Open your XtraScheduler application.
  2. Choose Add New Item from the Project menu.
  3. Choose XtraScehduler Report Class. This will add a new blank scheduler report to your application.
  4. Visual Studio will display the report designer for the newly constructed instance (it's called XtraSchedulerReport1 by default). Open the Visual Studio Toolbox pane and open the DX: Scheduler Reporting tab. Drag and drop a DayViewTimeCells control onto the Detail Band of the report.
    You'll notice that an instance of the ReportDayView component is created automatically and placed in the component tray.
  5. Add a HorizontalResourceHeaders control. Place it above the DayViewTimeCells control, again in the Detail Band.
  6. Add a HorizontalDateHeaders control. Place it above the HorizontalResourceHeaders control, and resize it as needed. Its width will determine the width of the time cell area.
  7. Use the smart tag of the HorizontalResourceHeaders control to link it to the HorizontalDateHeaders control. Now the control is linked to the data provider (ReportDayView) and is anchored to the date headers.
  8. Use the smart tag of the DayViewTimeCells control to link it to the HorizontalResourceHeaders control.
  9. Add a DayViewTimeRuler control, and place it on the left side of the DayViewTimeCells control. Click its smart tag and link it to the DayViewTimeCells control. The time ruler is now also linked to the data provider (ReportDayView) and anchored to the time cells. Resize it if necessary for proper alignment.
  10. Add a TimeInfoControl and a CalendarControl to the Detail Band. Place them above all the other controls, at the top of the page. Use their smart tags to link them to the DayViewTimeCells control.

The resulting designer view looks like this. You can easily identify the various controls used (each has a link icon).


You can preview the report by clicking on the Preview tab in the designer. Within Visual Studio, some fake data is generated to populate the preview, however, if you invoke the end-user designer at run-time, the data you see will be "real".

Use the following code to create the report at run time and bind it to the Scheduler control in your application:

using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Reporting;

      XtraSchedulerReport1 xr = new XtraSchedulerReport1();
      SchedulerControlPrintAdapter scPrintAdapter = new SchedulerControlPrintAdapter(this.schedulerControl1);
      xr.SchedulerAdapter = scPrintAdapter;


      // The line below invokes the End-User Designer

The preview looks like this:


So, there you have it: creating a great-looking scheduler report in DXperience v2009 vol 1. Remember, although this is part of XtraScheduler, it does require XtraReports in order to function, so you must have licenses to both, or a license to a superset package containing them both, like DXperience Enterprise.

Not too long to go before we release, so be ready to enjoy using this new functionality when we do.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.