ComponentOne FlexReport for WinForms
Showing or Hiding a Field Depending on a Value
Working with FlexReport > Modifying the Fields > Showing or Hiding a Field Depending on a Value

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 inserted a new field Shape field named "Shapefld" around the product name and set its Shape property to True, then you could write the script as follows:

   
If UnitsInStock < ReorderLevel Then 
Shapefld.Visible = True
Else
Shapefld.Visible = False
End If

To highlight products that are below the reorder level using code:

To highlight products that are below the reorder level by displaying a box, use an event script that looks like this:

Dim script As String = _   
  "If UnitsInStock < ReorderLevel Then" & vbCrLf & _
  "  BoxCtl.Visible = True" & vbCrLf & _   
  "Else" & vbCrLf & _   
  "  BoxCtl.Visible = False" & vbCrLf & _   
  "End If"   
C1FlexReport1.Sections.Detail.OnPrint = script
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";   
c1FlexReport1.Sections.Detail.OnPrint = script;

The code builds a string containing the VBScript event handler, and then assigns it to the section's OnPrint property.

To highlight products that are below the reorder level using FlexReportDesigner:

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 OnPrint property. Complete the following steps:

  1. Select Detail from the Properties window drop-down list in the Designer. This reveals the section's available properties.
  2. Click the ellipsis next to the OnPrint property, to open VBScript Editor.
  3. In the VBScript Editor, simply type the following script:
    
    If UnitsInStock < ReorderLevel Then 
    Shapefld.Visible = True
    Else
    Shapefld.Visible = False   
    End If
    

The following screen capture shows a section of the report with the special effects:

 Show or Hide a Shape Field in FlexReport