XtraReportBase.GetCurrentColumnValue<T>(String) Method
Returns the current value (strongly typed) of the specified column (field) from a collection assigned to a report’s Data Member property. If the property is not specified, the method returns the current value from a root collection of the report’s Data Source.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
columnName | String | A column (field) name. |
Type Parameters
Name | Description |
---|---|
T | A value type. |
Returns
Type | Description |
---|---|
T | The current column (field) value. If the specified column (field) was not found, the method returns null. |
Remarks
Call the GetCurrentColumnValue method in control event handlers (for example, in a BeforePrint handler).
private void xrLabel1_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var currValue = GetCurrentColumnValue<string>("CategoryName");
}
Business objects (such as Object Data Source, EF Data Source, or XPO Data Source) might contain methods or properties with custom logic. To get the current value from such methods or properties, use the GetCurrentRow method. Call this method to obtain a business object, then get a value from the object’s method or property.
Get the Current Column (Field) Value in a Detail Report
To get the current column (field) value from a collection assigned to a detail report’s Data Member (Data Source) property, call the detail report’s GetCurrentColumnValue method in control event handlers (for example, in a BeforePrint handler).
private DevExpress.XtraReports.UI.DetailReportBand DetailReport1;
private void xrLabel2_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var currValue = DetailReport1.GetCurrentColumnValue<string>("ProductName");
}
You can also use a control’s Report property to access the report to which the control belongs. This property can be useful if your report consists of multiple nested detail reports, and you want to access a control’s detail report in a control event handler.
using DevExpress.XtraReports.UI;
// ...
private void xrLabel3_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var label = sender as XRLabel;
var currValue = label.Report.GetCurrentColumnValue<string>("ProductName");
}