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.v18.2.dll
Declaration
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.
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();
}
Related GitHub Examples
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.