Triggering a checkbox value changed event in DataGridView

前端 未结 15 2891
一生所求
一生所求 2020-12-01 08:02

I have a grid view that has a check box column, and I want to trigger a drawing event as soon as the value of the cell is toggled. I tried the ValueChaged and the CellEndEdi

15条回答
  •  眼角桃花
    2020-12-01 08:14

    I had the same issue, but came up with a different solution:

    If you make the column or the whole grid "Read Only" so that when the user clicks the checkbox it doesn't change value.

    Fortunately, the DataGridView.CellClick event is still fired. In my case I do the following in the cellClick event:

    if (jM_jobTasksDataGridView.Columns[e.ColumnIndex].CellType.Name == "DataGridViewCheckBoxCell")
    

    But you could check the column name if you have more than one checkbox column.

    I then do all the modification / saving of the dataset myself.

提交回复
热议问题