根据条件来判断某一个单元格的值是否为可编辑,关键是datagridview中的CellBeginEdit
1 private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
2 {
3 var dgv = (DataGridView)sender;
4 string name ="wtq";
5 string cellText = Convert.ToString(dgv[0,e.RowIndex].Value) ;
6 if (cellText.Equals(name))
7 {
8 e.Cancel = true;
9 }
10
11 }
2 {
3 var dgv = (DataGridView)sender;
4 string name ="wtq";
5 string cellText = Convert.ToString(dgv[0,e.RowIndex].Value) ;
6 if (cellText.Equals(name))
7 {
8 e.Cancel = true;
9 }
10
11 }