Cell Mouse Down

This event is raised when the mouse is pressed down inside a visible cell.

Note that the Cell property of the event argument may be null. ReoGrid does not create a cell instance if no data or styles have been set on the cell.

To always get a non-null cell instance, use the CreateAndGetCell method of the worksheet instead of getting the instance from the event argument.

Attach the event:

var sheet = grid.CurrentWorksheet;
sheet.CellMouseDown += sheet_CellMouseDown;

Event handler body:

void sheet_CellMouseDown(object sender, CellMouseEventArgs e)
{
  // unsafe: cell instance may be null
  var cell = e.Cell;

  // safe: cell instance is created from position if it does not exist
  var sheet = grid.CurrentWorksheet;
  var cell = sheet.CreateAndGetCell(e.CellPosition);
}
Was this article helpful?