原創|其它|編輯:郝浩|2012-10-23 10:18:10.000|閱讀 521 次
概述:本文通過一個具體事例來給大家演示,如何實現DevExpress XtraGrid網格控求平均值、和、最大最小值。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文通過一個具體事例來給大家演示,如何實現DevExpress XtraGrid網格控求平均值、和、最大最小值。
灰色背景部分的數據,分別實現求平均值、和、最大最小值。
代碼如下:
C#
using DevExpress.Data.PivotGrid;
using DevExpress.XtraPivotGrid;
// Get a reference to the CategoryName field.
PivotGridField field = pivotGridControl1.Fields["CategoryName"];
pivotGridControl1.BeginUpdate();
try {
// Clear the custom total collection.
field.CustomTotals.Clear();
// Add four items to the custom total collection to calculate the Average,
// Sum, Max and Min summaries.
field.CustomTotals.Add(PivotSummaryType.Average);
field.CustomTotals.Add(PivotSummaryType.Sum);
field.CustomTotals.Add(PivotSummaryType.Max);
field.CustomTotals.Add(PivotSummaryType.Min);
// Make the custom totals visible for this field.
field.TotalsVisibility = PivotTotalsVisibility.CustomTotals;
}
finally {
pivotGridControl1.EndUpdate();
}
VB
Imports DevExpress.Data.PivotGrid
Imports DevExpress.XtraPivotGrid
' Get a reference to the CategoryName field.
Dim field As PivotGridField = pivotGridControl1.Fields("CategoryName")
pivotGridControl1.BeginUpdate()
Try
' Clear the custom total collection.
field.CustomTotals.Clear()
' Add four items to the custom total collection to calculate the Average,
' Sum, Max and Min summaries.
field.CustomTotals.Add(PivotSummaryType.Average)
field.CustomTotals.Add(PivotSummaryType.Sum)
field.CustomTotals.Add(PivotSummaryType.Max)
field.CustomTotals.Add(PivotSummaryType.Min)
' Make the custom totals visible for this field.
field.TotalsVisibility = PivotTotalsVisibility.CustomTotals
Finally
pivotGridControl1.EndUpdate()
End Try
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都控件網