xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-d27c1950.md
Occurs after a data-bound XRControl object obtains data from its data source.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public virtual event BindingEventHandler EvaluateBinding
Public Overridable Event EvaluateBinding As BindingEventHandler
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. |
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.
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 = "";//
}
}
Private Sub XtraReport1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
Dim report As XtraReport = TryCast(sender, XtraReport)
Dim list As List(Of XRControl) = report.AllControls(Of XRControl)().ToList()
For i As Integer = 0 To list.Count - 1
If TypeOf list(i) Is XRLabel OrElse TypeOf list(i) Is XRTableCell Then
AddHandler list(i).EvaluateBinding, AddressOf XtraReport1_EvaluateBinding
End If
Next i
End Sub
Private Sub XtraReport1_EvaluateBinding(ByVal sender As Object, ByVal e As BindingEventArgs)
If TypeOf e.Value Is Date Then
If TypeOf sender Is XRLabel Then
TryCast(sender, XRLabel).TextFormatString = ""
End If
If TypeOf sender Is XRTableCell Then
TryCast(sender, XRTableCell).TextFormatString = ""
End If
End If
End Sub
See Also