Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    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.1.dll

    NuGet Package: DevExpress.Win.Gantt

    #Declaration

    [DXCategory("Events")]
    public event QueryItemTemplateEventHandler QueryItemTemplate

    #Event Data

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

    Property Description
    Item Gets the information about the processed UI element (regular task, summary task, baseline, etc.).
    ItemType Gets a value that identifies the element type (regular task, summary task, baseline, etc.).
    Template Gets 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.

    HTML templates in Gantt Control

    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;
        }
    }
    

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

    See Also