dimanche 20 juin 2021

Updating the value of a Checkbox column in datagridview in c# by code

I am trying to update the value of a checkbox column in datagridview in c# by code but it is not working. Here it is the code:

foreach (DataGridViewRow r in dgvAlumnos.Rows)
{
    if (attendance[r.Index] == true)
    {
        r.Cells[2].Value = true;
    }
    else
    {
        r.Cells[2].Value = false;
    }
}

Attendance is the array of booleans where I have the values.

The column number 2 of the datagridview is the checkbox column.

However, the changes are not visible in the datagriview. I am using this code inside the form construct.

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire