mercredi 17 juillet 2019

How to check more than one checkbox individually in DataGridView C#

I would like how to achieve this, I tried many of the solutions i found on here on SO but none of them worked

enter image description here

I want to be able to check for example the first and the second option but when i check one of them the others two are unchecked, how can avoid this?

I would like to know what events or properties i need to change to be able to select multiple checkboxes individually no using a master checkbox to select all of them, I hope you can help me thanks.

I tried this code in the CellClick event of the datagridview

var isChecked = (bool)DGVProductos.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

if (isChecked)
{
    foreach (DataGridViewRow row in DGVProductos.Rows)
    {
        if (row.Index != e.RowIndex)
        {
            row.Cells["CheckProducto"].Value = !isChecked;
        }
    }
}




Aucun commentaire:

Enregistrer un commentaire