Skip to main content

Standard Formatting Mechanism

  • 2 minutes to read

You can use the standard formatting mechanism to format display values. This mechanism allows you to apply standard format patterns to values. For instance, you can display a numeric value as currency, a hexadecimal value, scientific notation, etc. If you have a date/time value, you can use the standard Short Date, Long Date, or Full Date/Time format.

Data Cells

Specify a column editor’s EditPropertiesBase.DisplayFormatString property to format cell values.

<dxwgv:GridViewDataSpinEditColumn FieldName="Budget" VisibleIndex="2">
    <PropertiesSpinEdit DisplayFormatString="c2" NumberFormat="Custom">
    </PropertiesSpinEdit>
</dxwgv:GridViewDataSpinEditColumn>

The image below shows the result:

DataFormatting_Cells

Summary Values

Use a summary item’s ASPxSummaryItemBase.DisplayFormat property to format values displayed within summary cells.

<TotalSummary>
    <dxwgv:ASPxSummaryItem DisplayFormat="Count: {0}" FieldName="ID" ShowInColumn="ID"
        SummaryType="Count" />
    <dxwgv:ASPxSummaryItem DisplayFormat="Max Budget = {0:c2}" 
     FieldName="Budget" ShowInColumn="Budget"
        SummaryType="Max" />
</TotalSummary>

The image below shows the result:

DataFormatting_Summary

Group Rows

The ASPxGridViewSettings.GroupFormat property allows you to specify the text pattern for group rows. The text pattern can include static text and predefined placeholders.

This property’s default value is “{0}: {1} {2}“:

  • {0} - The placeholder for the group column’s caption.
  • {1} - The placeholder for the group column’s value, which corresponds to the current group row.
  • {2} - The placeholder for a group row’s summary text.
<dxwgv:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
     DataSourceID="AccessDataSource1" FilterEnabled="True" KeyFieldName="ID">
     ...
    <Settings ShowFooter="True" ShowGroupPanel="True" GroupFormat="{1}: {2}" />
    <GroupSummary>
        <dxwgv:ASPxSummaryItem DisplayFormat="{0} Departments" FieldName="Department"
        SummaryType="Count" />
    </GroupSummary>
</dxwgv:ASPxGridView>

The image below shows the result:

DataFormatting_Groups