Back to Devexpress

XRLabel.Summary Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrlabel-a9bb6350.md

latest6.9 KB
Original Source

XRLabel.Summary Property

Gets the value that was calculated for the data source field bound to the XRControl.Text property of the given label.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[Browsable(true)]
[SRCategory(ReportStringId.CatData)]
public XRSummary Summary { get; set; }
vb
<Browsable(True)>
<SRCategory(ReportStringId.CatData)>
Public Property Summary As XRSummary

Property Value

TypeDescription
XRSummary

An XRSummary object that represents the calculated numerical value.

|

Remarks

The calculated numerical value corresponds to one of the summary functions listed in the Expression Language topic. The report area, for which a function is calculated, is determined by the SummaryRunning enumeration. A format for the value returned by this property is set by the XRLabel.TextFormatString property.

To learn more about calculating summaries in XtraReports see the Calculate Summaries topics.

Note

If a label calculates a summary value, its XRLabel.CanShrink and XRLabel.CanGrow property values are ignored.

Example

The following example demonstrates how to set summary options for a label at runtime. The method below creates an XRSummary object, sets its properties, and sets the XRLabel.Summary property. This example assumes that there is an already existing XRLabel object, passed as a parameter and bound to a dataset field that contains a numerical value.

csharp
using DevExpress.XtraReports.UI;
// ...
public void SetFunction(XRLabel label) {
    // Create an XRSummary object. 
    XRSummary summary = new XRSummary();

    // Set a function which should be calculated. 
    summary.Func = SummaryFunc.Avg;

    // Set a range for which the function should be calculated. 
    summary.Running = SummaryRunning.Group;

    // Set the "ingore null values" option. 
    summary.IgnoreNullValues = true;

    // Set the "treat strings as numerics" option.
    summary.TreatStringsAsNumerics = true;

    // Set the output string format. 
    summary.FormatString = "{0:c2}";

    // Make the label calculate the specified function for the 
    // value specified by its DataBindings.Text property. 
    label.Summary = summary;
}
vb
Imports DevExpress.XtraReports.UI
' ...
Public Sub SetFunction(ByVal label As XRLabel)
    ' Create an XRSummary object. 
    Dim summary As New XRSummary()

    ' Set a function which should be calculated. 
    summary.Func = SummaryFunc.Avg

    ' Set a range for which the function should be calculated. 
    summary.Running = SummaryRunning.Group

    ' Set the "ingore null values" option. 
    summary.IgnoreNullValues = True

    ' Set the "treat strings as numerics" option.
    summary.TreatStringsAsNumerics = True

    ' Set the output string format. 
    summary.FormatString = "{0:c2}"

    ' Make the label calculate the specified function for the 
    ' value specified by its DataBindings.Text property. 
    label.Summary = summary
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the Summary property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

asp-net-web-forms-grid-create-report-based-on-grid-layout/CS/WebApplication1/ReportHelper.cs#L71

csharp
label.DataBindings.Add("Text", null, ((GridViewDataColumn)col).FieldName);
label.Summary = new XRSummary() { Running = SummaryRunning.Group };
label.Summary.FormatString = item.DisplayFormat;

asp-net-mvc-grid-create-report-based-on-grid-layout/CS/E4755/Models/ReportHelperMVC.cs#L55

csharp
label.DataBindings.Add("Text", null, col.FieldName);
label.Summary = new XRSummary() {
    Running = SummaryRunning.Report

asp-net-web-forms-grid-create-report-based-on-grid-layout/VB/WebApplication1/ReportHelper.vb#L73

vb
label.DataBindings.Add("Text", Nothing, CType(col, GridViewDataColumn).FieldName)
label.Summary = New XRSummary() With {.Running = SummaryRunning.Group}
label.Summary.FormatString = item.DisplayFormat

asp-net-mvc-grid-create-report-based-on-grid-layout/VB/E4755/Models/ReportHelperMVC.vb#L54

vb
label.DataBindings.Add("Text", Nothing, col.FieldName)
label.Summary = New XRSummary() With {.Running = SummaryRunning.Report}
label.Summary.FormatString = item.DisplayFormat

See Also

Calculate Summaries

Calculate Custom Summaries via Scripts

XRLabel Class

XRLabel Members

DevExpress.XtraReports.UI Namespace