If you want to add a ReportFooter section to a report designed with the specifications mentioned above, then in every case the ReportFooter section will always be orphaned on the last page. ReportFooter section can be very important for a report as there might be something which a user might want to display at the very end. Let us see how an orphaned ReportFooter looks like:
In the above case the NewPage property for the GroupFooter section is set "After", and once the last group is completely rendered, ActiveReports engine checks if there is any other data left to be printed on the report. Since it finds a ReportFooter section waiting to be printed (as it contains some control), it inserts a new page and therefore the ReportFooter is moved to the newly added page, leaving it orphaned.
The only way to solve this problem is to avoid using the ReportFooter section. This leads to another question that how will we be able to show the text we want to include in the ReportFooter section? Well the answer is pretty straightforward and we will be using the GroupFooter section to act like a ReportFooter. Let us find out how.
Consider an example where you are looking to show a text "Report Ends Here" once the report ends. Considering our case where we cannot place the label in the ReportFooter section, we will have to place it in the GroupFooter section. The problem now is that the label will appear on every GroupFooter section. So we will keep the visible property of this label to false initially, setting it from the properties window.
Since the label is now invisible, it will not appear on all the GroupFooter sections of the report. Now the only catch here is that we have to make the label visible once the last GroupFooter renders and to do this we need to know the number of main groups which are present in the report. This can be done by writing a query which does this work and also provides us a connection with the datasource. The images below from the connection dialog box and the designer will make it clearer:
Once we have written the query, we will get an additional field in the ReportExplorer which can be dragged and dropped onto the GroupFooter section. The purpose of doing this is that on every GroupFooter Format event we will check whether the current group number is equal to the total number of groups and once the condition satisfies, we will make the label visible. So the code looks something like:
int currentgroupno = 1;
private void groupFooter1_Format(object sender, EventArgs e)
textBox1.Text = "End Of Group " + currentgroupno.ToString();
//txtNoOfCountries1 is the field which contains the value for the total number of groups
if (currentgroupno == int.Parse(txtNoOfCountries1.Text))
label2.Visible = true;
A working example demonstrating this functionality can be downloaded from the following links.
Download Sample C#
Download Sample VB.NET