原創(chuàng)|其它|編輯:郝浩|2012-10-23 10:18:10.000|閱讀 521 次
概述:本文通過一個具體事例來給大家演示,如何實現(xiàn)DevExpress XtraGrid網(wǎng)格控求平均值、和、最大最小值。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文通過一個具體事例來給大家演示,如何實現(xiàn)DevExpress XtraGrid網(wǎng)格控求平均值、和、最大最小值。
灰色背景部分的數(shù)據(jù),分別實現(xiàn)求平均值、和、最大最小值。
代碼如下:
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
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)