This project is read-only.

Iterate Cells

ReoGrid provides a method named IterateCells which is used to iterate through all valid cells. ReoGrid uses a paging-indexed two-dimensional array to manage all cells in memory. IterateCells method can skip the empty cells, empty index-pages and merged cells in order to get better performance.

public void IterateCells(ReoGridRange range, Func<int, int, ReoGridCell, bool> iterator)
public void IterateCells(int row, int col, int rows, int cols, Func<int, int, ReoGridCell, bool> iterator)
grid.IterateCells(range, (row, col, cell) =>
  // return true to continue iterate, return false to abort
  return true;

Skip conditions


IterateCells method skips the following objects:
  • Empty cells - A cell without any data and own styles set, it will be skipped during iteration
  • Empty index-pages - An index-page without any cells attached, it will be skipped during iteration
  • Invalid cells - A cell merged by another cell, it will become invalid and skipped by this method


A sample to sum values through inside a specified range. (the code-behind of sum function)
public static double Sum(ReoGridControl ctrl, ReoGridRange range)
  double val = 0;

  ctrl.IterateCells(range, (row, col, cell) =>
    if (ScriptRunningMachine.IsNumber(cell.Data))
      val += ScriptRunningMachine.GetDoubleValue(cell.Data);
    return true;

  return val;

Next: Control Appearance

Last edited Feb 5, 2014 at 3:14 PM by unvell, version 7