Skip to main content
A newer version of this page is available. .

PivotGridCells.GetCellInfo(Int32, Int32) Method

Returns an object that contains information on the specified cell.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v19.1.dll

Declaration

public PivotCellEventArgs GetCellInfo(
    int columnIndex,
    int rowIndex
)

Parameters

Name Type Description
columnIndex Int32

A zero-based integer that identifies the visible index of the column.

rowIndex Int32

A zero-based integer that identifies the visible index of the row.

Returns

Type Description
PivotCellEventArgs

A PivotCellEventArgs object that contains information on the specified cell.

Remarks

The GetCellInfo method returns a PivotCellEventArgs object that contains information on the specified cell. It specifies the type of the cell, the cell’s value and display text, whether it is focused or selected, etc. It also lets an array of records associated with this cell to be retrieved via the PivotCellEventArgsBase<TField, TData, TCustomTotal>.CreateDrillDownDataSource method.

To identify a cell, pass the indexes of the row and column that contain the cell as the GetCellInfo method parameters. The valid row indexes lie between 0 and PivotGridCells.RowCount - 1. The valid column indexes lie between 0 and PivotGridCells.ColumnCount - 1.

The PivotGridCells.FocusedCell property identifies the indexes of the row and column that contain the focused cell. To get the coordinates of the selected cells, use the PivotGridCells.Selection property.

Use the PivotGridCells.GetFocusedCellInfo method to get information on the focused cell.

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);
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetCellInfo(Int32, Int32) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also