CalculatedFieldCollection Class

A collection of CalculatedField objects.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.1.dll

Syntax

public class CalculatedFieldCollection :
    Collection<CalculatedField>,
    IList<CalculatedField>,
    ICollection<CalculatedField>,
    IList,
    ICollection,
    IReadOnlyList<CalculatedField>,
    IReadOnlyCollection<CalculatedField>,
    IEnumerable<CalculatedField>,
    IEnumerable<ICalculatedField>,
    IEnumerable,
    IDisposable

This collection is returned via the XtraReport.CalculatedFields property. For more information on using calculated data fields in XtraReports, refer to the Calculated Fields Overview document.

Examples

This example demonstrates how a calculated field can be created at runtime and bound to a control's XRControl.Text property.

using System;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Configuration;
// ...

private void button1_Click(object sender, EventArgs e) {

    // Create a report.
    XtraReport1 report = new XtraReport1();

    // Create a calculated field 
    // and add it to the report's collection.
    CalculatedField calcField = new CalculatedField();
    report.CalculatedFields.Add(calcField);

    // Define the calculated field's properties.
    calcField.DataSource = report.DataSource;
    calcField.DataMember = report.DataMember;
    calcField.FieldType = FieldType.Double;
    calcField.DisplayName = "Calculated Field";
    calcField.Name = "myField";
    calcField.Expression = "[UnitPrice] * [UnitsInStock]";

    // Bind a label's Text property to the calculated field.
    report.FindControl("xrlabel2", true).DataBindings.Add("Text", null, "Order Details.myField");

    // Bind a label's Text property to the calculated field 
    // depending on the report's data binding mode.
    if (Settings.Default.UserDesignerOptions.DataBindingMode == DataBindingMode.Bindings)
        report.FindControl("xrlabel3", true).DataBindings.Add("Text", null, "Products.myField", "{0:c2}");
    else report.FindControl("xrlabel3", true).ExpressionBindings.Add(
        new ExpressionBinding("BeforePrint", "Text", "FormatString('{0:c2}', [myField])"));

    // Display the report.
    ReportPrintTool printTool = new ReportPrintTool(report);
    printTool.ShowPreviewDialog();
}

Inheritance

Object
System.Collections.ObjectModel.Collection<CalculatedField>
CalculatedFieldCollection

Implements

System.Collections.Generic.IList<CalculatedField>
System.Collections.Generic.ICollection<CalculatedField>
System.Collections.Generic.IReadOnlyList<CalculatedField>
System.Collections.Generic.IReadOnlyCollection<CalculatedField>
System.Collections.Generic.IEnumerable<CalculatedField>

Inherited Members

System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Add(DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Clear()
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.CopyTo(DevExpress.XtraReports.UI.CalculatedField[], System.Int32)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Contains(DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.GetEnumerator()
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.IndexOf(DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Insert(System.Int32, DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Remove(DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.RemoveAt(System.Int32)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.ClearItems()
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.RemoveItem(System.Int32)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.SetItem(System.Int32, DevExpress.XtraReports.UI.CalculatedField)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IEnumerable.GetEnumerator()
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.ICollection.CopyTo(System.Array, System.Int32)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.get_Item(System.Int32)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.set_Item(System.Int32, System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.Add(System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.Contains(System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.IndexOf(System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.Insert(System.Int32, System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.Remove(System.Object)
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.Item[System.Int32]
System.Collections.ObjectModel.Collection<DevExpress.XtraReports.UI.CalculatedField>.System.Collections.IList.Item[System.Int32]
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()

See Also