PivotCellEventArgsBase<TField, TData, TCustomTotal>.GetCellValue(Int32, Int32) Method
Returns a cell value by the column and row indexes.
Namespace: DevExpress.XtraPivotGrid
Assembly: DevExpress.PivotGrid.v24.2.Core.dll
NuGet Packages: DevExpress.PivotGrid.Core, DevExpress.Win.Navigation
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
column |
Int32 | A zero-based integer that identifies the visible index of the column. |
row |
Int32 | A zero-based integer that identifies the visible index of the row. |
#Returns
Type | Description |
---|---|
Object | A value displayed in the specified cell. |
#Remarks
The e.ColumnIndex and e.RowIndex properties allow you to identify the processed cell.
Note
Note that the Get
method returns values calculated based on the data source data and ignores custom cell values suppled with the Custom
#Example
This example calculates percentage based on the Beverages row value for each column. The Pivot Grid handles the PivotGridControl.CustomCellValue event to display a calculated percentage value in the cell that belongs to the % of Beverages Sales column. The grand total values are hidden.
private void pivotGridControl1_CustomCellValue(object sender, PivotCellValueEventArgs e) {
// Calculates the 'Percent' field values.
if (e.DataField.Name == "PercentOfBeverages") {
// Hides grand total values.
if (e.RowValueType == PivotGridValueType.GrandTotal) {
e.Value = null;
return;
}
var rowValues = e.GetRowFields().Select(f =>
f == fieldCategoryName ? "Beverages" : e.GetFieldValue(f)).ToArray();
var columnValues = e.GetColumnFields().Select(f =>
f == fieldCategoryName ? "Beverages" : e.GetFieldValue(f)).ToArray();
decimal beveragesValue = Convert.ToDecimal(e.GetCellValue(columnValues, rowValues, e.DataField));
if (beveragesValue == 0)
e.Value = null;
else
e.Value = Convert.ToDecimal(e.Value) / beveragesValue;
}
else return;
}