Example 4. Calculating total |
Top Previous Next |
In this example, we will show how to calculate the sum by using programming methods. We will use the following:
Create a report of the following form:
In the script, declare the "sum" variable and create a BeforePrint event handler belonging to the band:
public class ReportScript { private decimal sum;
private void Data1_BeforePrint(object sender, EventArgs e) { sum += (Decimal)Report.GetColumnValue("Products.UnitPrice"); } }
The "Products.UnitPrice" data column can be placed into the script, dragging it from the "Data" window.
If you run the report, you will see the following:
The same effect can be achieved by using totals.
|