The event handler receives an argument of type PivotCustomCellEditEventArgs containing data related to this event.
The following
PivotCustomCellEditEventArgs properties provide information specific to this event.
Property |
Description |
ColumnCustomTotal |
Gets the column custom total which displays the current cell.
|
ColumnField |
Gets the innermost column field which corresponds to the processed cell.
|
ColumnFieldIndex |
For internal use.
|
ColumnIndex |
Gets the visual index of the column that contains the processed cell.
|
ColumnValueType |
Gets the type of column which contains the processed cell.
|
Data |
For internal use.
|
DataField |
Gets the data field which identifies the column where the processed cell resides.
|
Item |
For internal use.
|
RepositoryItem |
Gets or sets the in-place editor for the current cell.
|
RowCustomTotal |
Gets the row custom total which contains the current cell.
|
RowField |
Gets the innermost row field which corresponds to the processed cell.
|
RowFieldIndex |
For internal use.
|
RowIndex |
Gets the index of the row that contains the processed cell.
|
RowValueType |
Gets the type of row which contains the processed cell.
|
SummaryType |
Gets the summary type of the currently processed value.
|
SummaryValue |
Gets the summary value currently being processed.
|
Value |
Gets the processed cell's value.
|
You can use a data field's PivotGridField.FieldEdit property to assign an editor for all cells corresponding to this field. The CustomCellEdit event allows you to assign editors for particular cells. While handling this event, set the event's RepositoryItem parameter to the repository item representing the required in-place editor. Note that the repository item must be added to the control's RepositoryItems collection.
Cell editors are used for two purposes: they edit cells, and they define the appearance of cells in display mode (when data editing is not active).
If you want to use different editors in display and edit modes, you need to:
The following code shows how to handle the CustomCellEdit event, to assign different in-place editors to different types of cells.
In the example, two in-place editors (repository items) are created to represent values of the "Quantity %" field. A ProgressBar editor is used to represent regular cell values, while a SpinEdit editor is used to represent total values for this field:
C#:Form1.cs |
using System;
using System.Windows.Forms;
using DevExpress.Data.PivotGrid;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraPivotGrid;
namespace PivotGridControl_CustomCellEdit {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
RepositoryItemProgressBar riProgressBar = new RepositoryItemProgressBar();
RepositoryItemSpinEdit riSpinEdit = new RepositoryItemSpinEdit();
private void Form1_Load(object sender, EventArgs e) {
this.salesPersonTableAdapter.Fill(this.nwindDataSet.SalesPerson);
fieldQuantityPercent.SummaryDisplayType = PivotSummaryDisplayType.PercentOfColumn;
fieldQuantityPercent.CellFormat.FormatType = DevExpress.Utils.FormatType.Custom;
fieldQuantityPercent.CellFormat.FormatString = "{0}%";
pivotGridControl1.RepositoryItems.AddRange(new RepositoryItem[] { riProgressBar, riSpinEdit });
pivotGridControl1.CustomCellEdit += new
EventHandler<PivotCustomCellEditEventArgs>(pivotGridControl1_CustomCellEdit);
}
private void pivotGridControl1_CustomCellEdit(object sender, PivotCustomCellEditEventArgs e) {
if (e.DataField == fieldQuantityPercent) {
if (e.RowValueType == PivotGridValueType.Value)
e.RepositoryItem = riProgressBar;
if (e.RowValueType == PivotGridValueType.GrandTotal)
e.RepositoryItem = riSpinEdit;
}
}
private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e) {
if (e.DataField == fieldQuantityPercent)
e.Value = Convert.ToDecimal(e.Value) * 100;
}
}
}
|
C#:Program.cs |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace PivotGridControl_CustomCellEdit {
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
|
VB:Form1.vb |
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraPivotGrid
Namespace PivotGridControl_CustomCellEdit
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Dim riProgressBar As New RepositoryItemProgressBar()
Dim riSpinEdit As New RepositoryItemSpinEdit()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.salesPersonTableAdapter.Fill(Me.nwindDataSet.SalesPerson)
fieldQuantity1.SummaryDisplayType = DevExpress.Data.PivotGrid.PivotSummaryDisplayType.PercentOfColumn
fieldQuantity1.CellFormat.FormatType = DevExpress.Utils.FormatType.Custom
fieldQuantity1.CellFormat.FormatString = "{0}%"
pivotGridControl1.RepositoryItems.AddRange(New RepositoryItem() {riProgressBar, riSpinEdit})
End Sub
Private Sub pivotGridControl1_CustomCellEdit(ByVal sender As Object,
ByVal e As PivotCustomCellEditEventArgs) Handles pivotGridControl1.CustomCellEdit
If e.DataField Is fieldQuantity1 Then
If e.RowValueType = PivotGridValueType.GrandTotal Then
e.RepositoryItem = riSpinEdit
End If
If e.RowValueType = PivotGridValueType.Value Then
e.RepositoryItem = riProgressBar
End If
End If
End Sub
Private Sub pivotGridControl1_CustomCellValue(ByVal sender As Object,
ByVal e As PivotCellValueEventArgs) Handles pivotGridControl1.CustomCellValue
If e.DataField Is fieldQuantity1 Then
e.Value = Convert.ToDecimal(e.Value) * 100
End If
End Sub
End Class
End Namespace
|
VB:Program.vb |
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Windows.Forms
Namespace PivotGridControl_CustomCellEdit
Friend NotInheritable Class Program
Private Sub New()
End Sub
<STAThread> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
End Namespace
|