The last record of grouping

Stimulsoft Reports.NET discussion
Post Reply
isoft
Posts: 55
Joined: Fri Sep 08, 2006 9:33 am
Location: Croatia

The last record of grouping

Post by isoft »

Hi. Is it possible to find out when we are printing the last record of grouping? For instance, I have a GroupHeader and a DataBand. What I need to know is when is the last row of a group being printed. Lets say that I have a Table with my contacts. I group these contacts in my report by the first letter of ther Surname. I need to know when is the last name in the group which starts with A being printed?
I know it's pretty complicated idea, but if it is possible, it would be ecellent.

Thanks!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

The last record of grouping

Post by Edward »

The idea is very simple. You may use a trick with the report.
1. Set for the DataBand ResetDataSource property in true.
2. Place the group header with copy of the databand before your group in the begin of the report.
3. Please set the height of that groupheader and the databand to zero.
4. In the BeforePrintEvent of the DataBand you can fill an array with one column in it. In that column you should store a count of the Lines in each group.
5. Please define two variables in Dictionary. Indexer of the current group and counter for counting records in group. An array may be declared on the Code Tab of the report.
6. In BeforePrintEvent of the GroupHeader you can set an indexer for the array. In the BeforePrintEvent of the DataBand please count current row of the array.

Now we can control our group and to know the last row of each group.
in the BeforePrintEvent of the DataBand please compare a "Line" system variable and totalcount for that group from our array which will have been ready from our previous group.

Thank you.

Post Reply