GanttControl.CustomDrawTask Event
Fires before a task in the chart area is displayed. Provides access to a drawing surface and allows you to draw the task manually.
Namespace: DevExpress.XtraGantt
Assembly: DevExpress.XtraGantt.v24.2.dll
Declaration
Event Data
The CustomDrawTask event's data class is CustomDrawTaskEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appearance | Provides access to the task’s appearance settings. |
Cache | Provides access to the drawing surface and a cache of brushes, pens, fonts, and other graphics. Inherited from CustomDrawEventArgs. |
Duration | Gets the task duration. |
FinishDate | Gets the task finish date. |
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. |
Info | Provides access to view information about the task. |
Node | Gets the processed node. |
Progress | Gets the task progress. |
StartDate | Gets the task start date. |
State | Gets the object state: normal, hot tracked, pressed, disabled, or selected. |
The event data class exposes the following methods:
Method | Description |
---|---|
DefaultDraw() | Draws the visual element in its default appearance. Inherited from CustomDrawEventArgs. |
DrawBaseline() | Draws the baseline. |
DrawBaseline(RectangleF) | Draws the baseline in the specified bounds. |
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. |
DrawInsideText() | Draws the text inside the bar. |
DrawLeftLinkPoint() | Draws a dependency connection point at the left side of the task. |
DrawLeftText() | Draws the text to the left of the bar. |
DrawLeftText(RectangleF) | Draws the text to the left of the bar within the specified bounds. |
DrawRightLinkPoint() | Draws a dependency connection point at the right side of the task. |
DrawRightText() | Draws the text to the right of the bar. |
DrawRightText(RectangleF) | Draws the text to the left of the bar within the specified bounds. |
DrawShape() | Draws the task shape: bar, summary bar, or milestone. |
DrawShape(DateTime, DateTime) | Draws the task shape (bar, summary bar, or milestone) with an interruption. |
DrawShape(RectangleF, Single) | Draws the task shape: bar, summary bar, or milestone. |
DrawSplit(RectangleF) | Draws a task splitter. |
GetPosition(DateTime) | Returns the horizontal position of the specified date on the timescale. |
Example
The code below shows how to highlight specific tasks and dependencies.
HashSet<int> tasks = new HashSet<int> { 1, 2, 3, 6, 7, 8, 10, 11, 13 };
ganttControl.CustomDrawTask += (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.CustomDrawTaskDependency += (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;
}
};
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawTask event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.