Skip to main content
A newer version of this page is available. .

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.v20.2.dll

NuGet Package: DevExpress.Win.Gantt

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
Column Gets the processed column.

The event data class exposes the following methods:

Method Description
DrawBackground() Draws the background.
DrawHeader() Draws the header.
GetPosition(DateTime) Returns the position of the column that corresponds to the specified date.

Examples

The code below shows how to display a deadline.

Run Demo: Draw 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.

Run Demo: 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