The requested page is not available for the requested platform. You are viewing the content for Default platform.

XtraReportBase.GetCurrentRow() Method

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public object GetCurrentRow()
Public Function GetCurrentRow As Object

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.

Examples

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();
}
See Also