private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { try { if ((this.dataGridView1.Columns[e.ColumnIndex].Name == "STATUS")) { if (Convert.ToString(e.Value) == "Cleared") { e.CellStyle.BackColor = Color.YellowGreen; e.CellStyle.ForeColor = Color.Blue; } } } catch (Exception ex1) { MessageBox.Show(ex1.ToString()); } }
try { if ((this.dataGridView1.Columns[e.ColumnIndex].Name == "STATUS")) { if (Convert.ToString(e.Value) == "Cleared") { DataGridViewCellStyle cs = new DataGridViewCellStyle(); cs.ForeColor = Color.Red; cs.BackColor = Color.Yellow; e.CellStyle.BackColor = Color.YellowGreen; e.CellStyle.ForeColor = Color.Blue; e.FormattingApplied = true; dataGridView1.Rows[e.RowIndex].Cells["UNITSLNO"].Style = cs; } } } catch (Exception ex1) { MessageBox.Show(ex1.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)