Hiding a Section if There is No Data for It
You can change a report field’s format based on its data by specifying an expression for the Detail section’s Section.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 Section.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:
C1Report1.Sections.Detail.OnPrint = "Detail.Visible = not
isnull(PictureFieldName)"
• C#
c1Report1.Sections.Detail.OnPrint = "Detail.Visible = not
isnull(PictureFieldName)";
To hide a section if there is no data for it using the C1ReportDesigner:
Alternatively, instead of writing the code, you can use the C1ReportDesigner 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 Script Editor from the list.
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)
|