Coloring in particular cells using data grid
foreach (DataGridViewRow dataGridViewRow in dataGridView1.Rows)
{
DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
dataGridViewCellStyle.ForeColor = Color.Red;
if (dataGridViewRow.Cells[2].Value != null)
{
if (dataGridViewRow.Cells[2].Value.ToString().Trim().Equals("M", StringComparison.CurrentCultureIgnoreCase))
{
dataGridViewRow.DefaultCellStyle = dataGridViewCellStyle;
}
}
}