All docs
V21.2
21.2
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

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.v21.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.
GetPosition(DateTime) Returns the position of the column that corresponds to the specified date.

Examples

The code below shows how to display a deadline.

image

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.

image

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