在 datagridview c# 中使一个单元格可编辑

Abe*_*uez 5 c# gridview datagridview winforms

我有一个 datagrid 视图,其属性为 readonly = true; 但我想设置一些单元格可编辑,我尝试使用下一个代码来做到这一点:

this.dgvNoCargadas.Rows[index].Cells[columns].ReadOnly = false;
Run Code Online (Sandbox Code Playgroud)

但我无法修改网格,有人有什么想法吗?

小智 5

首先删除 dgv readonly true 然后

  foreach (DataGridViewRow row in DataGridView1.Rows)
  {
      if (condition for true)
      {
          row.Cells[2].ReadOnly = true;
      }
      else (condition for false)
      {
          row.Cells[2].ReadOnly = false;
      }
  }
Run Code Online (Sandbox Code Playgroud)