Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GetValueEventArgs Class

Provides data for the CalculatedField.GetValue event.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

public class GetValueEventArgs :
    EventArgs,
    IDisposable

#Remarks

The CalculatedField.GetValue event occurs when a calculated field obtains its value, enabling you to return a custom value for this calculated field. The GetValueEventArgs class introduces the GetValueEventArgs.Value property, which accepts the final calculated value for a calculated field, and the GetValueEventArgs.Row and GetValueEventArgs.Report properties, which enable you to obtain any information required to calculate a value for a calculated field.

Note

GetValueEventArgs objects are automatically created, initialized and passed to the CalculatedField.GetValue event handlers.

#Example

The report created in this example is bound to the “Orders” table of the sample Northwind database.

To sort records by days of the week at runtime, do the following.

  1. Create a calculated field with the CalculatedField.FieldType property set to String. Add a GroupHeader band, and add a grouping criteria (with the GroupField.FieldName property set to the created calculated field) to its GroupHeaderBand.GroupFields collection.
  2. Then, drop the calculated field from the Field List onto the GroupHeader1 band for the XRLabel control (named hdrLabel) bound to the field to be automatically created.
  3. Handle the calculated field’s CalculatedField.GetValue and the hdrLabel‘s XRControl.BeforePrint event handlers in the following way.
using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...

private void calculatedField1_GetValue(object sender, GetValueEventArgs e) {
    object columnValue = e.GetColumnValue("OrderDate");
    e.Value = (int)((DateTime)columnValue).DayOfWeek;
}

private void hdrLabel_BeforePrint(object sender, System.ComponentModel.EventArgs e) {
    hdrLabel.Text = ((DayOfWeek)this.GetCurrentColumnValue(this.calculatedField1.Name)).ToString();
}

#Inheritance

Object
EventArgs
GetValueEventArgs
See Also