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, in this case a record's image, for it, use an event script that looks like this:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
C1Report1.Sections.Detail.OnFormat = "Detail.Visible = not isnull(PictureFieldName)" |
To write code in C#
C# |
Copy Code
|
---|---|
c1Report1.Sections.Detail.OnFormat = "Detail.Visible = not isnull(PictureFieldName)"; |
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:
If isnull(PictureFieldName) Then
Detail.Visible = false
Else
Detail.Visible = true
End If
Detail.Visible = not isnull(PictureFieldName)