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

XtraReportBase.GetCurrentColumnValue(String) Method

Gets the current value of the specified column in the report's XtraReportBase.DataSource.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public object GetCurrentColumnValue(
    string columnName
)
Public Function GetCurrentColumnValue(
    columnName As String
) As Object

Parameters

Name Type Description
columnName String

A String, which specifies the name of the column whose value is to be obtained.

Returns

Type Description
Object

An object which represents the current value of the specified column in the data source. If the specified column was not found, this method returns null (Nothing in Visual Basic).

Remarks

Use the GetCurrentColumnValue, XtraReportBase.GetPreviousColumnValue and XtraReportBase.GetNextColumnValue methods to determine the value of the specified data column when creating a report, for example, in the XRControl.BeforePrint event handler.

To avoid casting the object returned by this method to an appropriate type, use the XtraReportBase.GetCurrentColumnValue<T> method, which returns a strongly typed object.

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