CellMouseDown

This event will be raised if mouse pressed down inside a visible cell.

Note that the Cell property of the event argument may be null. ReoGrid does not create any instances for cell if there was no data or styles set into the cell.

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

Attach 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 created from position if not existed
  var sheet = grid.CurrentWorksheet;
  var cell = sheet.CreateAndGetCell(e.CellPosition);
}

Return to Events

5 Responses to “CellMouseDown”

  1. Raza Sultan says:

    unvell.ReoGrid.ReoGridControl does not contain a definition for CellMouseDown.
    Please help for this.

    • jing says:

      Please use this firstly:
      var sheet = grid.CurrentWorksheet;

      The document has been corrected. Thanks for pointing out.

      • AB Zaman says:

        Adding the event as the above mentioned way gives the following error:

        “The variable ‘sheet’ is either undeclared or was never assigned.”

        When I select the ‘Go to code’ option it gives me following message:

        ‘Ignoring these exceptions will put the designer in an unstable state that could result in loss of controls. Do you want to continue?’

        When I continue, it is working but Im concerned if it will cause problems later

  2. Prakash says:

    Hi
    i tried above example code to check if user double clicked on some cell.
    Console.WriteLine(e.Clicks);

    every time it shows 1, for double click i get the same output twice
    i guess its pretty obvious!
    what is the correct way to check for cell double click?
    Thanks