Back to Devexpress

XRSummary Class

xtrareports-devexpress-dot-xtrareports-dot-ui-d26a9bc1.md

latest4.0 KB
Original Source

XRSummary Class

Provides methods that calculate arithmetic functions for the values in the data source field bound to the XRControl.Text property of the XRLabel control and its descendants.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class XRSummary :
    IDisposable,
    IXRControlContainer
vb
Public Class XRSummary
    Implements IDisposable,
               IXRControlContainer

The following members return XRSummary objects:

Remarks

The set of available functions is specified by the SummaryFunc enumeration. The report area for which a function is calculated is determined by the SummaryRunning enumeration.

To learn more about calculating summaries in reports, see the Calculate Summaries topic.

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

Inheritance

Object XRSummary

See Also

XRSummary Members

Calculate Summaries

DevExpress.XtraReports.UI Namespace