GridView.GroupFormat Property

Gets or sets the format rule that specifies a template for group row captions. You can build this template from custom text strings and the following placeholders: {0}, {1}, {2} and [#image].

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v21.2.dll

Declaration

[DefaultValue("{0}: [#image]{1} {2}")]
[XtraSerializableProperty]
[DXCategory("Appearance")]
public virtual string GroupFormat { get; set; }

Property Value

Type Default Description
String

“{0}: [#image]{1} {2}”

A string value specifying the text pattern for group rows.

Remarks

The default group format contains all four available placeholders: “{0}: [#image]{1} {2}”. For instance, “Category: <Image> Seafood (Count = 26)”.

GroupFormat

  • {0} - the group column caption. In the example above, {0} is a placeholder for “Category”.

  • {1} - the group column display text. In the example above, {1} is a placeholder for food categories (“Seafood”, “Grains and Cereals”, etc.). The {1} placeholder may insert a text string that differs from cell values. This happens when:

  • {2} - the group row summary text. In the example above, the {2} placeholder inserts the value of a summary item that calculates the number of records in each group. The code below creates a group summary item whose value is shown by the {2} placeholder.
gridView.GroupSummary.Add(new GridGroupSummaryItem() {
        FieldName = "UnitPrice",
        SummaryType = SummaryItemType.Count,
        ShowInGroupColumnFooter = null
    });

If you add multiple group row summaries, the {2} placeholder shows comma-separated values for all of them. For example: “Category: Beverage (Count=12),(MAX = 4.50)”.

  • [#image] - the group row image.

Use the GridView.GetGroupRowDisplayText method to return the currently displayed group row text.

The GroupFormat property affects all group rows in a View. You can also handle the GridView.CustomDrawGroupRow event to modify individual group rows’ captions (for instance, to add HTML tags).

See Also