mercredi 29 juin 2016

How to detect if checkbox changed in DataGridView?

In a winforms app, I have a cell with a checkbox. Once the user clicks this checkbox, I'd like to know. I have the following code that I've tried in the events below:

foreach (DataGridViewRow row in mygridview.Rows)
{
  if (Convert.ToBoolean(row.Cells[1].Value) {
    isChecked = true;
  }
}

I've tried the following DataGridView events with no success since Value is always null when the user is clicking the checkbox. When the user clicks a 2nd or more time, the above does capture all the previous checked checkboxes but it is too late by then. It still doesn't capture the current click.

CellClick()
CellLeave()
CellMouseUp()
CellValueChanged()
CurrentCellChanged()

Anyone have some suggestions?




Aucun commentaire:

Enregistrer un commentaire