Creating a Printed Report
The dbicDayView control is capable of producing a printed report using the built-in Print and PrintPreview methods. The contents of the report are based upon the PrintReportType property which can be set to Current to print only those columns, times, and appointments which are currently visible in the control, or Full to print all of the columns, times, and appointments in the control as a whole.
Example: Send the entire contents of the control to a printer selected by the user.
[VB.NET]
'Set the control to print all items and all time bars
Me.dbicDayView1.PrintReportType = Dbi.WinControl.DayView.enumPrintReportType.Full
'Send the report to the printer
Me.dbicDayView1.Print()
[C#]
//Set the control to print all items and all time bars
this.dbicDayView1.PrintReportType = Dbi.WinControl.DayView.enumPrintReportType.Full;
//Send the report to the printer
this.dbicDayView1.Print();
It is important to note that the control requires the page settings of the device that will be rendering the output, i.e. the printer or destination print preview printer prior to formatting the output. Accordingly, when the Print() or PrintPreview() methods are called directly, the user will be required to select a printer and optional page settings (Landscape/Portrait etc.) from the standard dialog before the output can be formatted. To override this behavior the developer has the option of providing the page settings to the method directly by specifying a custom printDialog object or a printerSettings object that describes the page settings for the output via one of the 2 overloads available;
dbicDayView1.Print(printDialog As System.Windows.Forms.PrintDialog)
dbicDayView1.Print(printSettings As System.Drawing.Printing.PrinterSettings)
dbicDayView1.PrintPreview(printDialog As System.Windows.Forms.PrintDialog)
dbicDayView1.PrintPreview(printSettings As System.Drawing.Printing.PrinterSettings)
If the page settings are passed in to the Print or PrintPreview methods via one of its overloads, the user will not be prompted with a printer dialog and the output will be formatted based on the page settings provided through specified parameter.
Example: Send the entire contents of the control to Print Preview using the default printer set to landscape mode.
[VB.NET]
'Create a new PrinterSettings object
'NOTE: When a new PrinterSettings object is created it is assigned the default printer and its default settings
Dim printPreviewSettings As New Printing.PrinterSettings
printPreviewSettings.DefaultPageSettings.Landscape = True
Me.dbicDayView1.PrintPreview(printPreviewSettings)
[C#]
//Create a new PrinterSettings object
//NOTE: When a new PrinterSettings object is created it is assigned
//the default printer and its default settings
System.Drawing.Printing.PrinterSettings printPreviewSettings = new System.Drawing.Printing.PrinterSettings();
printPreviewSettings.DefaultPageSettings.Landscape = true;
this.dbicDayView1.PrintPreview(printPreviewSettings);
Prior to sending the output to the Print or PrintPreview methods the developer can customize the report using the following Properties:
| Property | Type | Description |
| PrintDisplayColumns | Integer | Determines the number of columns in the printed report |
| PrintFont | Font | Determines the title font in the printed report |
| PrintFooterAlign | enum | Determines the alignment of the print footer |
| PrintPageText | Text | Determines the text describing the page number |
| PrintReportType | enum | Determines the type of printed report to produce |
| PrintSubTitle | Text | Determines the sub title for the printed report |
| PrintTimeEnd | Integer | Determines the ending time of a printed report |
| PrintTimeStart | Integer | Determines the starting time of a printed report |
| PrintTitle | Text | Determines the title for the printed report |
| PrintTitleAlign | Enum | Determines the alignment of the print title |