Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XRControl.EvaluateBinding Event

Occurs after a data-bound XRControl object obtains data from its data source.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

public virtual event BindingEventHandler EvaluateBinding

#Event Data

The EvaluateBinding event's data class is BindingEventArgs. The following properties provide information specific to this event:

Property Description
Binding Provides the information about a control’s bindings in the XRControl.EvaluateBinding event handler.
Value Specifies a new value for a control’s bound property obtained in the XRControl.EvaluateBinding event handler.

#Remarks

The EvaluateBinding event is raised before the XRControl.BeforePrint event rises. In this event handler, you can perform custom calculations over data obtained from a control’s data source, that for any reason cannot be evaluated via Calculated Fields Overview.

In this event handler, you can access the information from a control’s XRBinding object (via the BindingEventArgs.Binding property), and assign a new value to the BindingEventArgs.Value property.

This event does not fire for data fields that are embedded into an XRControl‘s text using mail merge.

#Example

The following code snippet changes date format for all controls that obtain DateTime value at runtime:

private void XtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
    XtraReport report = sender as XtraReport;
    List<XRControl> list = report.AllControls<XRControl>().ToList();
    for (int i = 0; i < list.Count; i++)
    {
        if (list[i] is XRLabel || list[i] is XRTableCell)
            list[i].EvaluateBinding += XtraReport1_EvaluateBinding;                    
    }
}

private void XtraReport1_EvaluateBinding(object sender, BindingEventArgs e)
{
    if (e.Value is DateTime)
    {
        if (sender is XRLabel)
            (sender as XRLabel).TextFormatString = "";//
        if (sender is XRTableCell)
            (sender as XRTableCell).TextFormatString = "";//
    }
}
See Also