XtraReportBase.GetCurrentColumnValue<T>(String) Method
Gets the current value (strongly typed) of the specified column in the report’s DataSource.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v20.1.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. |
Type Parameters
Name |
---|
T |
Returns
Type | Description |
---|---|
T | A <T> object that corresponds to 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
Call the GetCurrentColumnValue<T> method in the XRControl.BeforePrint event handler to obtain the current strongly-typed value of the specified data source property (for instance, when you bind a report to the SQL data source).
If you want to cast the returned object automatically, use the XtraReportBase.GetCurrentColumnValue method.
Note
In a detail report, call the DetailReportBand‘s GetCurrentColumnValue<T> method to retrieve the current value of the specified data source property.
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);
}