Skip to main content

GridSummaryItem.DisplayFormat Property

Gets or sets the display format rule for the GridSummaryItem value. An empty string to apply the default format rule.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v22.2.dll

NuGet Package: DevExpress.Win.Grid

Declaration

[DefaultValue("")]
[DXCategory("Format")]
[XtraSerializableProperty(100)]
public string DisplayFormat { get; set; }

Property Value

Type Default Description
String String.Empty

A string that specifies the display format rule for the GridSummaryItem.

Remarks

The display format rule syntax is:

<custom text>{0<:format specifier<precision specifier>>}<custom text>

  • custom text - any custom string displayed before and after the summary value.
  • ‘{0}’ - the placeholder for the summary value.
  • format specifier - specifies the summary value format.
  • precision specifier - the number of digits after the decimal point.

The Create total and group summaries demo illustrates how to apply display format rules to total and group summary items.

GridSummaryItem_DisplayFormat

gridView.OptionsView.ShowFooter = true;
gridView.Columns["Mark"].Group();

// Creating total and group summaries
GridColumn column = gridView.Columns["Length"];
column.SummaryItem.SummaryType = SummaryItemType.Sum;
// format the total summary
column.SummaryItem.DisplayFormat = "Total: {0:n3}";
// group summary
gridView.GroupSummary.Add(SummaryItemType.Count, "Mark");

gridView.GroupSummary.Add(new GridGroupSummaryItem()
{
    FieldName = "Length",
    SummaryType = SummaryItemType.Sum,
    DisplayFormat = "Sum: {0:n5}",
    ShowInGroupColumnFooter = gridView.Columns["Length"]
});
See Also