All docs
V21.1
21.1
20.2
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

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.v21.1.dll

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