XtraReportBase.GetCurrentColumnValue(String) Method
Gets the current value of the specified column in the report’s DataSource.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v20.2.dll
NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
columnName | String | The name of the column to obtain the value from. |
Returns
Type | Description |
---|---|
Object | The current value of the specified column in the report’s XtraReportBase.DataSource. If the specified column was not found, this method returns null (Nothing in Visual Basic). |
Remarks
Call the GetCurrentColumnValue method in the XRControl.BeforePrint event handler to obtain the current value of the specified data source property (for instance, when you bind a report to the SQL data source).
Note
In a detail report, call the DetailReportBand‘s GetCurrentColumnValue method to retrieve the current value of the specified data source property.
If you do not want to cast the returned object, use the XtraReportBase.GetCurrentColumnValue<T> method, which returns a strongly typed object.
Use the GetCurrentRow method instead if you have a business object and want to get the value of its method or field that implements custom logic (for instance, if you use the object data source, EF data source or XPO data source).
Example
This example demonstrates how to use the GetCurrentColumnValue method to filter the XRPivotGrid data.
The example assumes that your report is bound to the Northwind database’s SalesPerson view. The report data is grouped against the Country member. The Group Header band contains the label that displays the current country and the XRPivotGrid control as shown below.
When the report is previewed, the XRPivotGrid displays the entire data set in each group (that is, displays information for all countries regardless of the group settings).
This example shows how use the GetCurrentColumnValue method to obtain the current group value (the current country) and filter the XRPivotGrid by this country.
using DevExpress.Data.Filtering;
// ...
private void xrPivotGrid1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
// Retrieve the "Country" column's current value.
string country = GetCurrentColumnValue<string>("Country");
// Filter the Pivot Grid by the retrieved value.
xrPivotGrid1.Prefilter.Criteria = new BinaryOperator(
new OperandProperty("Country"),
new ConstantValue(country),
BinaryOperatorType.Equal);
}
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.