原創(chuàng)|其它|編輯:郝浩|2012-11-07 17:09:01.000|閱讀 761 次
概述:本文運(yùn)用PivotGridControl.CustomCellEdit事件,分配不同的In-place Editors 給不同類型的單元格。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文運(yùn)用PivotGridControl.CustomCellEdit事件,分配不同的In-place Editors 給不同類型的單元格。
在該示例中,兩個(gè)In-place Editors 被創(chuàng)建來代表“Qty %”字段的值。其中, ProgressBar編輯器是用來表示常規(guī)的單元格的值,而SpinEdit編輯器用來表示此字段的總額:
代碼如下:
C#
using DevExpress.XtraEditors.Repository; using DevExpress.XtraPivotGrid; // In-place editors used to represent values of regular and total cells respectively. RepositoryItemProgressBar editorForCells; RepositoryItemSpinEdit editorForTotals; // Initialize the editors. editorForCells = new RepositoryItemProgressBar(); editorForCells.Minimum = 0; editorForCells.Maximum = 100; editorForTotals = new RepositoryItemSpinEdit(); pivotGridControl1.RepositoryItems.AddRange( new RepositoryItem[] { editorForCells, editorForTotals }); // Provide editors for cells depending on cell types private void pivotGridControl1_CustomCellEdit(object sender, PivotCustomCellEditEventArgs e) { if (e.DataField != fieldQuantityPercent) return; if (e.RowValueType == PivotGridValueType.GrandTotal) e.RepositoryItem = editorForTotals; if (e.RowValueType == PivotGridValueType.Value) e.RepositoryItem = editorForCells; }
VB
Imports DevExpress.XtraEditors.Repository Imports DevExpress.XtraPivotGrid ' In-place editors used to represent values of regular and total cells respectively. Dim editorForCells As RepositoryItemProgressBar Dim editorForTotals As RepositoryItemSpinEdit ' Initialize the editors. editorForCells = New RepositoryItemProgressBar() editorForCells.Minimum = 0 editorForCells.Maximum = 100 editorForTotals = New RepositoryItemSpinEdit() PivotGridControl1.RepositoryItems.AddRange(New RepositoryItem() _ {editorForCells, editorForTotals}) ' Provide editors for cells depending on cell types Private Sub PivotGridControl1_CustomCellEdit(ByVal sender As System.Object, _ ByVal e As PivotCustomCellEditEventArgs) Handles PivotGridControl1.CustomCellEdit If e.DataField <> fieldQuantityPercent Then Return If e.RowValueType = PivotGridValueType.GrandTotal Then e.RepositoryItem = editorForTotals If e.RowValueType = PivotGridValueType.Value Then e.RepositoryItem = editorForCells End Sub
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)