Skip to main content
A newer version of this page is available. .

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.v20.2.dll

NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core

Declaration

public T GetCurrentFieldValue<T>(
    string name
)

Parameters

Name Type Description
name String

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

Type Parameters

Name Description
T

The type of the resulting value.

Returns

Type Description
T

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

Remarks

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.

Example

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