Skip to the guide
All guides

Print the scheduler and the timeline

Print the current scheduler view or a period of the timeline. Add page headers and footers with page numbers, and show a preview before you print.

app Mordex Components 6.0.0checked reading 3 minutes

On this page

Two print documents turn the controls into pages. MxSchedulerPrintDocument prints an MxScheduler. MxTimelinePrintDocument prints an MxTimeline. Both are .NET PrintDocument classes, so they work with PrintDialog, PrintPreviewDialog and PrintPreviewControl.

The pages print with a light look, also when the window uses a dark theme.

Set Scheduler to the control to print. The document prints the view and the dates that the scheduler shows.

C#
using System;
using System.Windows.Forms;
using Mordex.Windows.Scheduler;

MxSchedulerPrintDocument document = new MxSchedulerPrintDocument();
document.Scheduler = scheduler;
document.DefaultPageSettings.Landscape = true;

using (PrintPreviewDialog dialog = new PrintPreviewDialog())
{
    dialog.Document = document;
    dialog.ShowDialog(this);
}

Choose what a page holds

DayViewPrintMode sets how the day view is split into pages.

ValuePages
DayViewPrintMode.PagePerDayOne page for each day. This is the default.
DayViewPrintMode.PagePerViewOne page for all the days in the view.
Values of DayViewPrintMode

StartTime and EndTime set the hours to print in the day view. By default they follow WorkStartTime and WorkEndTime of the scheduler.

C#
document.DayViewPrintMode = DayViewPrintMode.PagePerView;
document.StartTime = TimeSpan.FromHours(7);
document.EndTime = TimeSpan.FromHours(19);

For the week and month views, LayoutPages can spread the view over LayoutPages.TwoPages. The default is LayoutPages.OnePage. CompressWeekEnds puts Saturday and Sunday in one cell when the month view is printed.

ShowDateHeader prints the date header at the top of the page. It is on by default. MonthViewHeaderNaming sets the text of that header in month view.

The fonts are HeaderFont, FooterFont, DateHeadingsFont, DayFont, WeekFont and MonthFont.

Set Timeline to the control to print. By default the document prints the dates that are on screen. Set StartDate and EndDate to print another period.

C#
using System;
using System.Windows.Forms;
using Mordex.Windows.Timeline;

MxTimelinePrintDocument document = new MxTimelinePrintDocument();
document.Timeline = timeline;
document.StartDate = new DateTime(2026, 11, 1);
document.EndDate = new DateTime(2027, 1, 31);
document.PrintCollapsedRows = false;

using (PrintPreviewDialog dialog = new PrintPreviewDialog())
{
    dialog.Document = document;
    dialog.ShowDialog(this);
}

PrintCollapsedRows sets whether the rows of closed groups are printed. PrintExpandBox sets whether the open and close box of each group is printed. Both are on by default.

PrepareDocument works out the pages before printing. After it runs, TotalPages gives the number of pages, and the page range of PrinterSettings covers all pages.

C#
document.PrepareDocument();
int pages = document.TotalPages;

Add headers and footers

Each document has a left, center and right text for the top and the bottom of the page.

PlaceScheduler documentTimeline document
Top leftHeaderLeftPageHeaderLeft
Top centerHeaderCenterPageHeaderCenter
Top rightHeaderRightPageHeaderRight
Bottom leftFooterLeftPageFooterLeft
Bottom centerFooterCenterPageFooterCenter
Bottom rightFooterRightPageFooterRight
Header and footer properties

The text can hold these codes. The document puts in the value when it prints.

CodePrinted value
[Page #]The number of the page.
[Total Pages]The number of pages.
[Date Printed]The date of printing.
[Time Printed]The time of printing.
[User Name]The name of the Windows user.
Codes in header and footer text
C#
schedulerDocument.HeaderCenter = "Team calendar";
schedulerDocument.FooterCenter = "Page [Page #] of [Total Pages]";
schedulerDocument.FooterRight = "[Date Printed]";

timelineDocument.PageHeaderCenter = "Project plan";
timelineDocument.PageFooterCenter = "Page [Page #] of [Total Pages]";

The timeline document also has PageHeaderFont and PageFooterFont.

Note

A preview needs an installed printer. Without one, .NET cannot draw the preview pages.