Skip to main content

XRCrossTabCell.GetCurrentFieldValue<T>(String) Method

Gets the current value (strongly typed) of the specified data source field.

Namespace: DevExpress.XtraReports.UI.CrossTab

Assembly: DevExpress.XtraReports.v24.1.dll

NuGet Package: DevExpress.Reporting.Core


public T GetCurrentFieldValue<T>(
    string name


Name Type Description
name String

The name of the data field to obtain the value from.

Type Parameters

Name Description

The type of the resulting value.


Type Description

The current value of the specified data source field. If the specified field was not found, this method returns null (Nothing in Visual Basic).


Call the GetCurrentFieldValue<T> method in the XRCrossTabCell.BeforePrint event handler to obtain the current strongly-typed value of the specified data source field. If you want to cast the returned object automatically, use the GetCurrentFieldValue method.


This example demonstrates how to handle a Cross Tab cell’s BeforePrint event and customize the cell’s appearance based on its current value and row index.

using System.Drawing;
using DevExpress.XtraReports.UI.CrossTab;
// ...
private void xrCrossTabCell3_BeforePrint(object sender, CrossTabCellPrintEventArgs e) {
    // Obtain the current cell.
    XRCrossTabCell cell = (XRCrossTabCell)sender;

    // Change the cell's foreground color if its value exceeds 3000.
    decimal value = cell.GetCurrentFieldValue<decimal>("Extended Price");
    if (value > 3000)
        cell.ForeColor = Color.Red;
    else cell.ForeColor = Color.Black;

    // Apply different background colors to odd and even rows.
    if (e.GroupRowIndex % 2 == 0)
        cell.BackColor = Color.LightCyan;
    else cell.BackColor = Color.White;

See Also