GanttControl.CustomDrawTimescaleColumn Event
Fires before a column in the chart area is displayed. Provides access to a drawing surface and allows you to draw the column manually.
Namespace: DevExpress.XtraGantt
Assembly: DevExpress.XtraGantt.v24.2.dll
Declaration
[DXCategory("Events")]
public event CustomDrawTimescaleColumnEventHandler CustomDrawTimescaleColumn
Event Data
The CustomDrawTimescaleColumn event's data class is CustomDrawTimescaleColumnEventArgs. 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. |
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. |
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. |
DrawHeader() | Draws the header. |
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements. |
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. |
GetPosition(DateTime) | Returns the position of the column that corresponds to the specified date. |
Examples
The code below shows how to display a deadline.
DateTime deadLine = TaskStorage.GetFinishDateFromTask("Deploy Beta");
ganttControl.CustomDrawTimescaleColumn += (sender, e) => {
GanttTimescaleColumn column = e.Column;
if(column.StartDate <= deadLine && column.FinishDate >= deadLine) {
e.DrawBackground();
float x = (float)e.GetPosition(deadLine); float width = 4;
RectangleF deadLineRect = new RectangleF(x, column.Bounds.Y, width, column.Bounds.Height);
e.Cache.FillRectangle(DXSkinColors.FillColors.Danger, deadLineRect);
e.DrawHeader();
e.Handled = true;
}
};
The code below shows how to draw striplines.
DateTime striplineStart = DateTime.Now.AddHours(5);
DateTime striplineEnd = striplineStart.AddHours(4);
Color striplineColor = Color.FromArgb(128, 255, 224, 166);
ganttControl.CustomDrawTimescaleColumn += (sender, e) => {
GanttTimescaleColumn column = e.Column;
float stripLineStartPoint = (float)Math.Max(e.GetPosition(striplineStart), column.Bounds.Left);
float stripLineEndPoint = (float)Math.Min(e.GetPosition(striplineEnd), column.Bounds.Right);
e.DrawBackground();
RectangleF boundsToDraw = new RectangleF(stripLineStartPoint, column.Bounds.Y, stripLineEndPoint - stripLineStartPoint, column.Bounds.Height);
if(boundsToDraw.Width > 0)
e.Cache.FillRectangle(striplineColor, boundsToDraw);
e.DrawHeader();
e.Handled = true;
};
See Also