I have a WinForms application and i use datagridview in form. The DataGridView have many checkbox columns and the cells can be selected and processed by code.
So it's possible to check/uncheck all cells or copy to/insert from clipboard. This works fine except the last selected checkbox. 1st value is not shown as long as the cell is selected.
I have tried to set SuspendLayout
, Refresh
, Update
and then ResumeLayout
. But any one of them does not work for me.
private void SetCheckBoxCells(bool value)
{
myDataGridView.SuspendLayout();
foreach (var cell in myDataGridView.SelectedCells)
{
(cell as DataGridViewCheckBoxCell).Value = value;
}
myDataGridView.Refresh();
myDataGridView.Update();
myDataGridView.ResumeLayout();
}
I expect that all cells are visually set/unset after click on the menu entry, but the last one is visually set after deselect the cells.