Skip to main content

PivotGridCells Class

Stores information on the cells displayed within the PivotGrid control.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v24.1.dll

NuGet Package: DevExpress.Win.PivotGrid

Declaration

public class PivotGridCells

The following members return PivotGridCells objects:

Remarks

The PivotGridControl.Cells property of the PivotGridCells class allows you to get view information on the cells displayed by the control and retrieve data associated with particular cells.

The PivotGridCells.ColumnCount and PivotGridCells.RowCount properties specify the number of columns and rows within the control. To iterate through and get information on particular cells, use the PivotGridCells.GetCellInfo method. It requires the indexes of the column and row which contain the desired cell to be passed as its parameters. The object returned by this method lets you determine the cell’s value and display text. If the cell represents a data cell (this displays a summary result) you can use the PivotCellEventArgsBase<TField, TData, TCustomTotal>.CreateDrillDownDataSource method to get a list of the records which are used to calculate the summary for this cell.

The PivotGridCells.FocusedCell and PivotGridCells.Selection properties allow you to get or set the focused cell and cell selection, respectively.

Example

The following example demonstrates how to manually copy the display text of the control’s selected cells to the Clipboard. The selected cells are identified by the PivotGridCells.Selection property.

You can also use the PivotGridCells.CopySelectionToClipboard method to copy the selected cells to the Clipboard.

using DevExpress.XtraPivotGrid;

const string CellDelimiter = "\t";
const string LineDelimiter = "\r\n";

void CopyToClipboard(Pivot Grid Control pivotGrid) {
   PivotGridCells cells = pivotGrid.Cells;
   // Get the coordinates of the selected cells.
   Rectangle cellSelection = cells.Selection;
   string result = "";
   // Get the index of the bottommost selected row.
   int maxRow = cellSelection.Y + cellSelection.Height - 1;
   // Get the index of the rightmost selected column.
   int maxColumn = cellSelection.X + cellSelection.Width - 1;
   // Iterate through the selected cells.
   for(int rowIndex = cellSelection.Y; rowIndex <= maxRow; rowIndex++) {
      for(int colIndex = cellSelection.X; colIndex <= maxColumn; colIndex++) {
         // Get the current cell's display text.
         result += cells.GetCellInfo(colIndex, rowIndex).DisplayText;
         if(colIndex < maxColumn) result += CellDelimiter;
      }
      if(rowIndex < maxRow) result += LineDelimiter;
   }
   // Copy the resulting text to the clipboard.
   Clipboard.SetDataObject(result);
}

Inheritance

Object
PivotGridCells
See Also