ComponentOne FlexReport for WinForms
Hiding a Section If there is No Data
Working with FlexReport > Modifying the Fields > Hiding a Section If there is No Data

You can change a report field's format based on its data by specifying an expression for the Detail section's OnFormat property.

For example, your Detail section has fields with an image control and when there is no data for that record's image you want to hide the record. To hide the Detail section when there is no data, in this case a record's image, add the following script to the Detail section's OnFormat property:

If isnull(PictureFieldName) Then
  Detail.Visible = false
 Else
  Detail.Visible = true
End If

To hide a section if there is no data for it using code:

To hide a section if there is no data, in this case a record's image, for it, use an event script that looks like this:

C1FlexReport1.Sections.Detail.OnFormat = "Detail.Visible = notisnull(PictureFieldName)"
c1FlexReport1.Sections.Detail.OnFormat = "Detail.Visible = notisnull(PictureFieldName)";

To hide a section if there is no data for it using FlexReportDesigner:

Alternatively, instead of writing the code, you can use the C1FlexReportDesigner to type the following script code directly into the VBScript Editor of the Detail section's OnFormat 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 empty box next to the Section.OnFormat property, then click the drop-down arrow, and select Expression Editor from the list. VBScript Editor window appears.
  3. In the VBScript Editor:
    • Simply type the following script in the window:
      If isnull(PictureFieldName) Then
      Detail.Visible = false
      Else
      Detail.Visible = true
      End If

    • Or you could use the more concise version:
      Detail.Visible = not isnull(PictureFieldName)