XRLabel.SummaryCalculated Event
在計算標籤的自動彙總值時發生。
命名空間:DevExpress.XtraReports.UI
程序集:DevExpress.XtraReports.v19.2.dll
#聲明
[DefaultBindableProperty("Text")]
public class XRTableCell :
XRLabel,
IBrickOwner,
IWeighty
#事件數據
所述SummaryCalculated事件處理程序接收的參數TextFormatEventArgs類型。以下屬性提供特定於此事件的信息。
屬性 | 描述 |
---|---|
格式 | 獲取應用於摘要文本的格式字符串。 |
文本 | 獲取或設置摘要文本格式事件Args的文本表示形式。應用了字符串格式的值。 |
值 | 獲取自動計算爲標籤摘要的值。 |
#備註
使用此事件可獲得爲標籤控件自動計算的摘要值。可以通過TextFormatEventArgs.Value屬性訪問此值。
注意:當需要爲主報表中的所有明細報表計算總計時,此事件很有用,因爲無法在XtraReports中自動計算此值。
#例子
本示例演示如何將XRLabel.SummaryCalculated事件用於標籤控件。在此示例中,報表的數據集包含兩個相關表。“ 類別”表綁定到主報表,並且“ 產品”表用作DetailReport的數據源,該數據源按類別提供了產品列表。
詳細信息報告計算每個產品的“ 單價”列的總和。此摘要是自動計算的。單價彙總的總計必須顯示在主報表中。您必須編寫自己的代碼來計算這種摘要。它無法自動計算,因爲UnitPrice列不屬於主報表的數據源。
您應該在明細報告中處理摘要標籤的SummaryCalculated事件。請注意,在觸發BeforePrint事件時,尚未計算彙總值;您應該使用SummaryCalculated獲得一個計算得出的彙總值。單個詳細報告的摘要在全局變量(GrandTotals)中遞增,然後打印在主報告的頁腳中。
using System.Drawing.Printing;
using DevExpress.XtraReports.UI;
// ...
// Grand total value.
double GrandTotals = 0;
// Add the summary value to the grand total.
private void lbUnitPriceTotal_SummaryCalculated(object sender, TextFormatEventArgs e) {
if(e.Value != null)
GrandTotals += Convert.ToDouble(e.Value);
}
// Set the grand total value to the label's text.
private void lbUnitPriceGrandTotal_BeforePrint(object sender, PrintEventArgs e) {
((XRLabel)sender).Text = GrandTotals.ToString();
}
https://docs.devexpress.com/XtraReports/DevExpress.XtraReports.UI.XRLabel.SummaryCalculated