xtrareports-devexpress-dot-xtrareports-dot-ui-dot-getvalueeventargs-3b4a4836.md
Gets or sets a value of a calculated field.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public object Value { get; set; }
Public Property Value As Object
| Type | Description |
|---|---|
| Object |
A Object representing a field’s value.
|
Use the Value property in the CalculatedField.GetValue event handler to obtain the current value of a calculated field, and to assign a custom value when it is calculated.
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.
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();
}
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports DevExpress.XtraReports.UI
' ...
Private Sub calculatedField1_GetValue(ByVal sender As Object, _
ByVal e As GetValueEventArgs) Handles calculatedField1.GetValue
Dim columnValue As Object = e.GetColumnValue("OrderDate")
e.Value = CInt(Fix((CDate(columnValue)).DayOfWeek))
End Sub
Private Sub hdrLabel_BeforePrint(ByVal sender As Object, _
ByVal e As System.ComponentModel.EventArgs) Handles hdrLabel.BeforePrint
hdrLabel.Text = (CType(Me.GetCurrentColumnValue(Me.calculatedField1.Name), _
DayOfWeek)).ToString()
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Value 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.
reporting-winforms-number-to-words/CS/WindowsFormsApplication1/XtraReport1.cs#L20
{
e.Value = NumberToWords(Convert.ToInt32(e.GetColumnValue("UnitPrice")));
}
reporting-winforms-number-to-words/VB/WindowsFormsApplication1/XtraReport1.vb#L18
Private Sub WordsUnitPrice_GetValue(ByVal sender As Object, ByVal e As GetValueEventArgs) Handles WordsUnitPrice.GetValue
e.Value = NumberToWords(Convert.ToInt32(e.GetColumnValue("UnitPrice")))
End Sub
See Also