Skip to main content
A newer version of this page is available. .

XtraReportBase.GetCurrentRow() Method

Returns the current data row in the report’s data source.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

public object GetCurrentRow()

Returns

Type Description
Object

A DataRowView value (if the report’s data source is a DataTable), or a collection item (if the report’s data source is an object implementing the IList interface).

Remarks

The report’s data source is assigned to the XtraReportBase.DataSource property.

Example

This example demonstrates how to use the XtraReportBase.GetCurrentRow and XtraReportBase.GetCurrentColumnValue methods in master-detail reports.

To be able to run this example, the sample application should contain a report that is bound to the Categories and Products tables in the demo Northwind database (the nwind.mdb file located in the directory, where you installed DevExpress demos), and the dataset for these tables should contain a master-detail relationship (CategoriesProducts).

In the following code, “DetailReport” is the name of the DetailReportBand that should be added when creating a master-detail report.

using System.Data;
using System.Drawing.Printing;
// ...

private void Detail_BeforePrint(object sender, PrintEventArgs e) {
   // Get the value of the current row in the master report.
   xrLabel1.Text = ((DataRowView)GetCurrentRow()).Row["CategoryName"].ToString();

   // Get the value of the current cell in the CategoryName column in the master report.
   xrLabel2.Text = GetCurrentColumnValue("CategoryName").ToString();
}

private void Detail1_BeforePrint(object sender, PrintEventArgs e) {
   // You shouldn't use the GetCurrentRow method in this way in a detail report.
   // ((DataRowView)GetCurrentRow()).Row["Categories.CategoriesProducts.ProductName"].ToString();

   // Get the value of the current row in the detail report.
   xrLabel3.Text = ((DataRowView)DetailReport.GetCurrentRow()).Row["ProductName"].ToString();

   // You shouldn't use the GetCurrentColumnValue method in this way in a detail report.
   // GetCurrentColumnValue("Categories.CategoriesProducts.ProductName").ToString();

   // Get the current value of the CategoryName data column in a detail report.
   xrLabel4.Text = DetailReport.GetCurrentColumnValue("ProductName").ToString();
}

The following code snippets (auto-collected from DevExpress Examples) contain references 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.

See Also