Skip to main content Skip to footer

How To: Toggle GroupFooter Visibility in C1Report

Grouping is one of the most commonly used feature when it comes to designing a report using C1Reports for Winforms. After designing the basic layout, you may decide that grouping the records by certain fields or some other criteria would make the report easier to read and analyze. Grouping allows you to separate the groups of records visually and display introductory and summary data for each group. It can vary from one report to another as the level of grouping and the implementation would be as per the requirements of the user. For more information on how to do this, you can refer to this documentation link. In this blog article, I would discuss a common scenario where the user wants to toggle the visibility of the GroupFooter section based on the number of records in the detail section of C1Report. The need arises when the number of records or any other summary information for the corresponding groups is displayed in the GroupFooter section and you wish to hide this section when there is a single record in the report's Detail section. This can be done using C1ReportDesigner**'s VBScript** editor itself. Reports can include embedded VBScript event handlers, making them self contained.

Counting Number of Records

The first step is to add a field in the GroupFooter section of the report which would count the number of records in that particular group. Then, set the Calculated property of this field to true and the Text property to Count(FieldName). This would display the number of records in each group rendered in the report.

Toggle Visibility

Now, you can easily toggle the visibility of the GroupFooter section depending on the value of the field added above by adding the following line of code to the OnFormat event of the GroupFooter section:

if Field1.value="1" then  
   GroupFooter0.visible= False  
else  
   GroupFooter0.visible= true  
end if

Conclusion

This blog explains how you can toggle the visibility of the GroupFooter section based on the number of records in a group. You may modify the code above according to your requirements. For the complete implementation, you can download the report XML from the link below : Download XML

MESCIUS inc.

comments powered by Disqus