using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Drawing; using System.Data; using FastReport; using FastReport.Data; using FastReport.Dialog; using FastReport.Barcode; using FastReport.Table; using FastReport.Utils; namespace FastReport { public class ReportScript { // The idea is to collect group totals on the first report pass, and to print // the collected values on the second pass. // The variable that we going to print in the group header. private int total; // The list that will hold totals for each group. private List<int> totals = new List<int>(); // This handler is called before printing the group header. To create this handler: // - select the group header; // - go Properties window; // - press "Events" button; // - select "BeforePrint" event and doubleclick it. private void GroupHeader1_BeforePrint(object sender, EventArgs e) { // Note: ((Int32)Report.GetVariableValue("Row#")) is a current group number; // this string is automatically inserted when you drag & drop // the "Row#" system variable from the Data Dictionary window to the script. // This value is not zero-based. int groupNumber = ((Int32)Report.GetVariableValue("Row#")); // If this pass is final, get the collected value. if (Engine.FinalPass) total = totals[groupNumber - 1]; } // This handler is called before printing the group footer. private void GroupFooter1_BeforePrint(object sender, EventArgs e) { // Note: Report.GetTotalValue("TotalProducts") is a total value; // this string is automatically inserted when you drag & drop // the "TotalProducts" total from the Data Dictionary window to the script. int totalValue = (int)Report.GetTotalValue("TotalProducts"); // if this pass is not final, add the total value to the totals list. if (!Engine.FinalPass) totals.Add(totalValue); } } }