Skip to main content

XtraReportBase.GetCurrentColumnValue(String) Method

Returns the current value 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.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public object GetCurrentColumnValue(
    string columnName
)

Parameters

Name Type Description
columnName String

A column (field) name.

Returns

Type Description
Object

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("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("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("ProductName");
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetCurrentColumnValue(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also