public void chang_color(int i, string str) { dataGridView1.Rows[i].Cells[str].ReadOnly = true; DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Style.BackColor = Color.Wheat; //cell.ReadOnly = true; cell.Value = "N"; cell.Style.BackColor = Color.White; dataGridView1.Rows[i].Cells[str] = cell; dataGridView1.Rows[i].Cells[str].Style.ForeColor = Color.White; dataGridView1.Rows[i].Cells[str].Style.SelectionBackColor = Color.White; dataGridView1.Rows[i].Cells[str].Style.SelectionForeColor = Color.White; }