XRCrossTabCell.GetCurrentFieldValue(String) Method
Gets the current value of the specified data source field.
Namespace: DevExpress.XtraReports.UI.CrossTab
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the data field to obtain the value from. |
Returns
Type | Description |
---|---|
Object | 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 method in the XRCrossTabCell.BeforePrint event handler to obtain the current value of the specified data source field. If you do not want to cast the returned object, use the GetCurrentColumnValue<T> method, which returns a strongly typed object.
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;
}