Progress® Telerik® Reporting R2 2017

Using Report Item Events

Each report item on a report exposes these events:

ItemDataBindingFires just before the item is bound to data.
ItemDataBoundFires just after the item is bound to data.
Note Note

The SubReport report item exposes one additional event: NeedDataSource. This event fires when the SubReport.ReportSource does not have data source bound to it.

Let us demonstrate this with a simple example. Suppose that we have a TextBox containing the job position of an employee. Assume that the TextBox's Value property equals "=Fields.JobPosition", where JobPosition is a column from the data source containing values like "Team Leader", "Senior Developer", "Junior Developer", "Quality Assurance", etc. For the sake of our example, suppose that we would like to color all developers in Blue.

First we need to attach to the TextBox's ItemDataBinding event. Double-click the event in the property grid and an event handler method will be automatically generated for you.

As explained in Understanding Events topic, the sender argument is in fact the processing TextBox that has already been data bound. The method will be called for each data row, i.e. for each employee we have in the data source. So the only thing we have left to do is cast the sender, check the position, and do the coloring if needed:


private void textBox1_ItemDataBinding(object sender, EventArgs e)
    Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)sender;
    Telerik.Reporting.Processing.IDataObject dataObject = (Telerik.Reporting.Processing.IDataObject)txt.DataObject;
    if ((string)dataObject["Title"] == "Developer")
        txt.Style.BackgroundColor = System.Drawing.Color.Blue;
Note Note

The provided example can be easily implemented using ConditionalFormatting, see Change row color based on a value in the row or Bindings, see Bindings.

See Also