void setDataGridViewRow(DataGridView dgv, int iCase) { for (int i = 0; i < dgv.RowCount; i++) { DataGridViewRow row = dgv.Rows[i]; for (int j = 0; j < row.Cells.Count; j++) { if (j < 2 || !IsEditableField(row.Cells[0].Value.ToString())) { row.Cells[j].ReadOnly = true; row.Cells[j].ToolTipText = "Not Editable"; } else row.Cells[j].ReadOnly = false; } } } }
Dynamically Set DataGridView Cells ReadOnly
private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (e.ColumnIndex < 2) { e.Cancel = true; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)