Hello. My goal is to pain the entire row fore color as Red. If the value of
column 24 is true (boolean), I wish to paint the row as Red. Otherwise,
leave row as default (no formatting). The Datagridview datasource is a
datatable. Currently my issue is that all records are painted red on the
Cell_Formatting event. But not all records meet the filter condition. Any
ideas why? Here is code snippet
private void dgvPolicies_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
DataView view = (DataView)dgvPolicies.DataSource;
foreach (DataRowView rowView in view)
{
//if (rowView.Row.ItemArray[3].ToString().ToLower() == "test")
if (rowView.Row.ItemArray[24].ToString() == bool.TrueString)
{
e.CellStyle.ForeColor = Color.Red;
}
}
}