This topic explains, with code examples, how to customize the Print Version of the WinGanttView control using the InitializeGanttView event.
The following table lists the topics required as a prerequisite to understanding this topic.
This topic contains the following sections:
At times, you may need to modify the WinGanttView control such that it affects the print version of the control but not the on-screen control. The InitializeGanttView event of the UltraGanttViewPrintDocument is used for this purpose.
The UltraGanttViewPrintDocument component renders the control’s information to the printer by creating an instance of the UltraGanttView control. When the UltraGanttView control instance is created, it is initialized based on the GanttView property and then the InitializeGanttView event is invoked to allow any further customizations to the control. This event can be used to set a different visual state of the UltraGanttView control for printing without modifying the control’s original or on-screen visual state.
The print version of the WinGanttView control can be customized in the following aspects:
Hiding columns that show on the screen but which you do not want to print.
Showing columns in the print that are not shown on the screen.
Changing the order of the columns
Changing appearances such as printing with a white background to save ink.
The following code affects the display of the printed UltraGanttView control, which is different from the on-screen control.
The sample code changes the position of the Resource Names column and modifies the cell appearance of the Resource Names column on the printed UltraGanttView control.
The following pictures demonstrate the difference between the on-screen version of the WinGanttView control (top) and its print version (bottom) as customized by the sample code.
In Visual Basic:
Private Sub ultraGanttViewPrintDocument1_InitializeGanttView(sender As Object, e As Infragistics.Win.UltraWinGanttView.Printing.InitializeGanttViewEventArgs)
' Change the position of the ‘Resource Names’ column
e.Control.GridSettings.ColumnSettings(TaskField.Resources).VisiblePosition = 1
' Change the cell appearance of the ‘Resource Names’ column
e.Control.GridSettings.ColumnSettings(TaskField.Resources).CellAppearance.BackColor = Color.White
End Sub
In C#:
private void ultraGanttViewPrintDocument1_InitializeGanttView(object sender, Infragistics.Win.UltraWinGanttView.Printing.InitializeGanttViewEventArgs e)
{
// Change the position of the ‘Resource Names’ column
e.Control.GridSettings.ColumnSettings [TaskField.Resources].VisiblePosition = 1;
// Change the cell appearance of the ‘Resource Names’ column
e.Control.GridSettings.ColumnSettings[TaskField.Resources].CellAppearance.BackColor = Color.White;
}
The following topics provide additional information related to this topic.