Skip to main content
All docs
V24.2
Bar

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 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

BarItemCustomDrawEventArgs.DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) Method

Paints the required HTML template inside an element that raised this event.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public void DrawHtml(
    HtmlTemplate template,
    Action<DxHtmlPainterArgs> setupArgs = null
)

#Parameters

Name Type Description
template HtmlTemplate

A template to draw.

#Optional Parameters

Name Type Default Description
setupArgs Action<DxHtmlPainterArgs> null

Sets up required properties of the DxHtmlPainterArgs object.

#Remarks

The DrawHtml method allows you to paint custom HTML templates inside DevExpress controls. For instance, the code below illustrates how to handle the GridView.CustomDrawCell event to paint a template stored in an HtmlTemplateCollection inside cells that belong to the “Name” column.

Static Custom Draw Template

void OnCustomDrawCell(object sender, RowCellCustomDrawEventArgs e) {
    e.DefaultDraw();
    e.Handled = true;
    if (e.Column.FieldName == "Name")
        e.DrawHtml(htmlTemplateCollection1[0]);
}

The optional setupArgs delegate allows you to set up additional settings: specify interactivity keys, modify drawing bounds, assign custom values to elements with ${FieldName} placeholders, and more.

The following example demonstrates how to clip the content based on the container bounds:

void OnCustomDrawCell(object sender, RowCellCustomDrawEventArgs e) {
    var clipInfo = e.Cache.SaveAndSetClip(e.Bounds);
    try {
        e.DrawHtml(templates[0]);
    } finally {
        e.Cache.ClipInfo.RestoreClipRelease(clipInfo);
    }
}

Read the following topic for more information and examples: Custom Draw Templates.

See Also