Skip to main content

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

GridOptionsView.AllowHtmlDrawGroups Property

Gets or sets whether HTML tags can be used to format text in group rows.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

#Declaration

[DefaultValue(true)]
[XtraSerializableProperty]
public virtual bool AllowHtmlDrawGroups { get; set; }

#Property Value

Type Default Description
Boolean true

true if HTML tags can be used to format text in group rows; otherwise, false.

#Property Paths

You can access this nested property as listed below:

Object Type Path to AllowHtmlDrawGroups
GridView
.OptionsView .AllowHtmlDrawGroups

#Remarks

You can format text in group rows via the GridView.CustomDrawGroupRow event. To supply the new text for group rows, cast the event’s e.Info object to the GridGroupRowInfo object and then set the e.Info.GroupText property to the required value.

The HTML Text Formatting topic covers HTML tags you can use to format text.

Another way to format text in group rows is to use the GridView.GroupFormat property.

#Example

The following example uses HTML tags to format text within group rows. The example handles the CustomDrawGroupRow event. In the example, when data is grouped by the “Quantity” column, group values are painted in different colors using the <color> tag. New display text for group rows is supplied via the e.Info.GroupText property.

GroupRows-HTML-tags-via-CustomDraw

using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;

gridView1.OptionsView.AllowHtmlDrawGroups = true;

private void gridView1_CustomDrawGroupRow(object sender, RowObjectCustomDrawEventArgs e) {
    GridView view = sender as GridView;
    GridGroupRowInfo info = e.Info as GridGroupRowInfo;
    if (info.Column.Caption == "Quantity") {
        int quantity = Convert.ToInt32(view.GetGroupRowValue(e.RowHandle, info.Column));
        string colorName = getColorName(quantity);
        info.GroupText = info.Column.Caption + ": <color=" + colorName + ">" + info.GroupValueText + "</color> ";
        info.GroupText += "<color=LightSteelBlue>" + view.GetGroupSummaryText(e.RowHandle) + "</color> ";
    }
}

string getColorName(int value) {
    if (value < 20) return "MediumOrchid";
    if (value >= 80) return "OrangeRed";
    return "Blue";
}
See Also