Back to Devexpress

GanttControl.QueryItemTemplate Event

windowsforms-devexpress-dot-xtragantt-dot-ganttcontrol.md

latest3.4 KB
Original Source

GanttControl.QueryItemTemplate Event

Allows you to assign HTML-CSS templates from the GanttControl.HtmlTemplates collection to UI elements of the required type.

Namespace : DevExpress.XtraGantt

Assembly : DevExpress.XtraGantt.v25.2.dll

NuGet Package : DevExpress.Win.Gantt

Declaration

csharp
[DXCategory("Events")]
public event QueryItemTemplateEventHandler QueryItemTemplate
vb
<DXCategory("Events")>
Public Event QueryItemTemplate As QueryItemTemplateEventHandler

Event Data

The QueryItemTemplate event's data class is QueryItemTemplateEventArgs. The following properties provide information specific to this event:

PropertyDescription
ItemGets the information about the processed UI element (regular task, summary task, baseline, etc.).
ItemTypeGets a value that identifies the element type (regular task, summary task, baseline, etc.).
TemplateGets the HTML-CSS template.

Remarks

The code below assigns the “TaskTemplate” template to regular and summary tasks, “TaskProgressTemplate” to progress lines of regular and summary tasks, and “TaskTextLabelTemplate” to text labels.

csharp
void GanttControl1_QueryItemTemplate(object sender, QueryItemTemplateEventArgs e) {
    switch(e.ItemType) {
        case GanttChartItemType.Task:
        case GanttChartItemType.SummaryTask:
            e.Template.Assign(TaskTemplate);
            break;
        case GanttChartItemType.Progress:
        case GanttChartItemType.SummaryTaskProgress:
            e.Template.Assign(TaskProgressTemplate);
            break;
        case GanttChartItemType.TextLabel:
            e.Template.Assign(TaskTextLabelTemplate);
            break;
    }
}
vb
Private Sub GanttControl1_QueryItemTemplate(ByVal sender As Object, ByVal e As QueryItemTemplateEventArgs)
    Select Case e.ItemType
        Case GanttChartItemType.Task, GanttChartItemType.SummaryTask
            e.Template.Assign(TaskTemplate)
        Case GanttChartItemType.Progress, GanttChartItemType.SummaryTaskProgress
            e.Template.Assign(TaskProgressTemplate)
        Case GanttChartItemType.TextLabel
            e.Template.Assign(TaskTextLabelTemplate)
    End Select
End Sub

See this documentation article for more information: HTML Templates in Gantt Control.

See Also

GanttControl Class

GanttControl Members

DevExpress.XtraGantt Namespace