1.In the case of ASP.NET projects, in the grid view's
RowDataBound
event you could do it like in the next example:
protected void _yourGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text == "someValue")
{
e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;
e.Row.Cells[0].BackColor = Color.Yellow;
}
}
}
2.In the case of Windows Forms you should use DataGridView objects, and to change the colors you have to do it by using
DataBindingComplete
event like in the next example:
private void _yourDataGridView_DataBindingComplete(object sender,
DataGridViewBindingCompleteEventArgs e)
{
if(condition)
{
_yourDataGridView.Item(0, 1).Style.ForeColor = Color.Red;
_yourDataGridView.Item(0, 1).Style.BackColor = Color.Yellow;
}
}