private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 0 && dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
{
string txtObra = "TxtObra"; // Substitua "TxtObra" pelo valor real que você está verificando
string cellValue = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
string cell2Value = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
if (cellValue.Contains(txtObra) && !cell2Value.Contains("MNO") && !cell2Value.Contains("EXT") && !cell2Value.Contains("PNO") && !cell2Value.Contains("ELE") && !cell2Value.Contains("EPA") && !cell2Value.Contains("PIL"))
{
e.CellStyle.BackColor = Color.White;
}
else if (cellValue.Contains(txtObra))
{
e.CellStyle.BackColor = Color.Red;
}
else if (!cell2Value.Contains("NORM"))
{
e.CellStyle.BackColor = Color.Orange;
}
else
{
e.CellStyle.BackColor = Color.Green;
}
}
}
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == 0 && dataGridView1.Rows[e.RowIndex].Cells[0].Value != null)
{
string txtObra = "TxtObra"; // Substitua "TxtObra" pelo valor real que você está verificando
string cellValue = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
string cell2Value = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
if (cellValue.Contains(txtObra) && !cell2Value.Contains("MNO") && !cell2Value.Contains("EXT") && !cell2Value.Contains("PNO") && !cell2Value.Contains("ELE") && !cell2Value.Contains("EPA") && !cell2Value.Contains("PIL"))
{
e.CellStyle.BackColor = Color.White;
}
else if (cellValue.Contains(txtObra))
{
e.CellStyle.BackColor = Color.Red;
}
else if (!cell2Value.Contains("NORM"))
{
e.CellStyle.BackColor = Color.Orange;
}
else
{
e.CellStyle.BackColor = Color.Green;
}
}
}