Formatting a field according to its value is probably the most common use for the Section.OnPrint property. Take for example a report that lists order values grouped by product. Instead of using an extra field to display the quantity in stock, the report highlights products that are below the reorder level by displaying their name in bold red characters.
To highlight products that are below the reorder level by displaying their name in bold red characters, use an event script that looks like this:
Alternatively, instead of writing the code, you can use the C1FlexReportDesigner application to type the following script code directly into the VBScript Editor of the Detail section's Section.OnPrint property. Complete the following steps:
If UnitsInStock < ReorderLevel Then
ProductNameCtl.ForeColor = RGB(255,0,0)
ProductNameCtl.Font.Bold = True
Else
ProductNameCtl.ForeColor = RGB(0,0,0)
ProductNameCtl.Font.Bold = False
End If
The control executes the VBScript code whenever the section is about to be printed. The script gets the value of the "ReorderLevel" database field and sets the "ProductName" report field's Field.Font.Bold and Field.ForeColor properties according to the value. If the product is below reorder level, its name becomes bold and red.
The following screen capture shows a section of the report with the special effects: