In case anybody wants this, this is what works. This is for a datagridview inside a GP Dynamics winform project.
private void dgvTransferPOs_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
var grid = sender as DataGridView;
if (Equals(grid, dgvTransferPOs))
{
// Using a well defined column
foreach (var row in grid.Rows.Cast<DataGridViewRow>())
{
// IsClosed is not visible, but we can still access the value
if (Convert.ToBoolean(row.Cells[5].Value))
{
row.DefaultCellStyle.BackColor = Color.Red;
}
}
}
else
{
// Using a well defined type
foreach (var row in grid.Rows.Cast<DataGridViewRow>())
{
// IsWorking is not visible, but we can still access the value
if ((row.DataBoundItem as PODOC).IsClosed)
{
row.DefaultCellStyle.BackColor = Color.Red;
}
//else
//{
// row.DefaultCellStyle.BackColor = Color.White;
//}
}
}
}