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.v22.2.dll
NuGet Package: DevExpress.Win.Grid
Declaration
[DefaultValue("{0}: [#image]{1} {2}")]
[DXCategory("Appearance")]
[XtraSerializableProperty]
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)”.
{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:
- a column’s in-place editor has a display format rule (see the RepositoryItem.DisplayFormat property);
- a column applies a format rule to all its cells (see the GridColumn.DisplayFormat and GridColumn.GroupFormat properties);
- the ColumnView.CustomColumnDisplayText event is handled to manually replace cell display text.
- {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.
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. To specify group row images, assign an ImageComboBox in-place editor (RepositoryItemComboBox) to a group column. Use the GridColumn.ColumnEdit property to specify an in-place editor.
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).