I need to enable/disable a row columns of a datagridview this can be easily done by looping all the rows after binding it.
But i want to do this while the data is binding… is there a way to do that? also how do i enable/disable a row cell?
dgvLayout.AutoGenerateColumns = false;
dgvLayout.DataSource = list;
in cell click but it does not work
if ((dgvLayout.Rows[e.RowIndex].Cells["colControlText"].Value.ToString()) == "-Invalid-")
{
if (e.ColumnIndex == 2 || e.ColumnIndex == 5)
{
return;
}
else if (e.ColumnIndex == 1)
{
return;
}
}
you can use this solution for enabling and disabling cell
To “disable” a cell, it must be read-only and grayed out somehow. This function enables/disables a DataGridViewCell: