GanttControl.CustomPrintTimescaleColumn Event
Fires before a timescale column (the header and the chart area) is printed. Provides access to the drawing surface and allows you to draw the column in a custom way.
Namespace: DevExpress.XtraGantt
Assembly: DevExpress.XtraGantt.v21.2.dll
NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Gantt
Declaration
[DXCategory("Events")]
public event CustomPrintTimescaleColumnEventHandler CustomPrintTimescaleColumn
Event Data
The CustomPrintTimescaleColumn event's data class is CustomPrintTimescaleColumnEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Cache | Provides access to the drawing surface and a cache of brushes, pens, fonts, and other graphics. Inherited from CustomDrawEventArgs. |
Column | Gets the processed column. Inherited from CustomDrawTimescaleColumnEventArgs. |
Handled | Gets or sets whether the event is handled and allows you to prevent the control from drawing the visual element in its default appearance. Inherited from CustomDrawEventArgs. |
PrintArea | Gets whether the print engine processes the timescale column’s header or chart area. |
The event data class exposes the following methods:
Method | Description |
---|---|
DefaultDraw() | Draws the visual element in its default appearance. Inherited from CustomDrawEventArgs. |
DrawBackground() | Draws the background. Inherited from CustomDrawTimescaleColumnEventArgs. |
DrawHeader() | Draws the header. Inherited from CustomDrawTimescaleColumnEventArgs. |
GetPosition(DateTime) | Returns the position of the column that corresponds to the specified date. Inherited from CustomDrawTimescaleColumnEventArgs. |
Remarks
Before a project is printed or exported, the control raises the following events that allow you to draw visual elements in a custom way:
CustomPrintTask—allows you to draw a Gantt bar. This event is equivalent to the CustomDrawTask event, which allows you to customize a Gantt bar when it is displayed onscreen.
CustomPrintTaskDependency—allows you to draw a dependency line. This event is equivalent to the CustomDrawTaskDependency event, which allows you to customize a dependency line when it is displayed onscreen.
CustomPrintTimescaleColumn
—allows you to draw a timescale column (the header, which displays the date, and the chart area). This event is equivalent to the CustomDrawTimescaleColumn event, which allows you to customize a timescale column when it is displayed onscreen.
Example
The code below shows how to highlight specific tasks and dependencies when the project is printed.
HashSet<int> tasks = new HashSet<int> { 1, 2, 3, 6, 7, 8, 10, 11, 13 };
ganttControl.CustomPrintTask += (sender, e) => {
int taskId = Convert.ToInt32(e.Node.GetValue("Id"));
if(tasks.Contains(taskId)) {
e.Appearance.BackColor = DXSkinColors.FillColors.Warning;
e.Appearance.ProgressColor = DXSkinColors.FillColors.Warning;
}
};
ganttControl.CustomPrintTaskDependency += (sender, e) => {
int predecessorId = Convert.ToInt32(e.PredecessorNode.GetValue("Id"));
int successorId = Convert.ToInt32(e.SuccessorNode.GetValue("Id"));
if(tasks.Contains(predecessorId) && tasks.Contains(successorId)) {
e.Appearance.BackColor = DXSkinColors.FillColors.Warning;
}
};