I am working with Win Forms and DataGridView control. My data gridview is not bound to a data source but columns and rows are added. On some condition I am making the grid view read only and trying to change the background color of each cell to gray. But the gray color appears and then goes back to white default.I am not able to understand why this is so.
Following are the events on the Data Grid View
- Cell End Edit
- EditingControlShowing
Code to make the grid readonly and set the background color
_dataGridView.ReadOnly=true;
foreach (DataGridViewRow row in _dataGridView.Rows)
{
row.DefaultCellStyle.BackColor = SystemColors.Control;
}
Kindly suggest