Instead of changing the field format to highlight its contents, you could set another field's Visible property to True or False to create special effects. For example, if you created a new field called "BoxCtl" and formatted it to look like a bold rectangle around the product name, then you could change the script as follows:
If UnitsInStock < ReorderLevel Then
BoxCtl.Visible = True
Else
BoxCtl.Visible = False
End If
To highlight products that are below the reorder level by displaying a box, use an event script that looks like this:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Dim script As String = _ "If UnitsInStock < ReorderLevel Then" & vbCrLf & _ " BoxCtl.Visible = True" & vbCrLf & _ "Else" & vbCrLf & _ " BoxCtl.Visible = False" & vbCrLf & _ "End If" c1r.Sections.Detail.OnPrint = script |
To write code in C#
C# |
Copy Code
|
---|---|
string script = "if (UnitsInStock < ReorderLevel) then\r\n" + "BoxCtl.Visible = true\r\n" + "else\r\n" + "BoxCtl.Visible = false\r\n" + "end if\r\n"; c1r.Sections.Detail.OnPrint = script; |
The code builds a string containing the VBScript event handler, and then assigns it to the section's OnPrint property.
Alternatively, instead of writing the code, you can use the C1ReportDesigner application to type the following script code directly into the VBScript Editor of the Detail section's OnPrint property. Complete the following steps:
If UnitsInStock < ReorderLevel Then
BoxCtl.Visible = True
Else
BoxCtl.Visible = False
End If
The following screen capture shows a section of the report with the special effects: