All guides
No guide matches your search.
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.
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.
Print the scheduler
Set Scheduler to the control to print. The document prints the view and the dates that the scheduler shows.
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.
| Value | Pages |
|---|---|
DayViewPrintMode.PagePerDay | One page for each day. This is the default. |
DayViewPrintMode.PagePerView | One page for all the days in the view. |
StartTime and EndTime set the hours to print in the day view. By default they follow WorkStartTime and WorkEndTime of the scheduler.
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.
Print the timeline
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.
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.
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.
| Place | Scheduler document | Timeline document |
|---|---|---|
| Top left | HeaderLeft | PageHeaderLeft |
| Top center | HeaderCenter | PageHeaderCenter |
| Top right | HeaderRight | PageHeaderRight |
| Bottom left | FooterLeft | PageFooterLeft |
| Bottom center | FooterCenter | PageFooterCenter |
| Bottom right | FooterRight | PageFooterRight |
The text can hold these codes. The document puts in the value when it prints.
| Code | Printed 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. |
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.
Was this page helpful?