XtraReportBase.GetCurrentRow() Method
Returns the current data row 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.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Returns
Type | Description |
---|---|
Object | The current data row. |
Remarks
Use the GetCurrentRow method when you bind a report to a business object (such as Object Data Source, EF Data Source, or XPO Data Source) to retrieve data from the object’s methods or properties with custom logic. Call the GetCurrentRow method in control event handlers (for example, in a BeforePrint handler) to obtain a business object, then get a value from the object’s method or property.
private void xrLabel1_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
var currRow = GetCurrentRow();
}
If you want to get the current value of a data source column (field), use the GetCurrentColumnValue(String) method instead.
Get the Current Row in a Detail Report
To get the current data row from a collection assigned to a detail report’s Data Member (Data Source) property, call the detail report’s GetCurrentRow 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 currRow = DetailReport1.GetCurrentRow();
}
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 currRow = label.Report.GetCurrentRow();
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetCurrentRow() 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.