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 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

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).

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