I have a gridView
where all the bank information is loaded from my SQLServer
.
My question is this. How do I change the font color when a date is less than the system date (for example, to redirect the accounts that are due)?
Follow my code to load gridView
and the screen:
private void CarregarGridContasPagarAberto()
{
IList<ContasPagarDTO> listaContasPagar = new List<ContasPagarDTO>();
listaContasPagar = new ContasPagarModel().CargaContasPagarAberto();
dgvContasPagar.AutoGenerateColumns = false;
dgvContasPagar.DataSource = listaContasPagar;
}
screen:
privatevoiddgvContasPagar_CellFormatting(objectsender,DataGridViewCellFormattingEventArgsArguments){IList<ContasPagarDTO>listaContasPagar=newList<ContasPagarDTO>();listaContasPagar=newContasPagarModel().CargaContasPagarAberto();if(this.dgvContasPagar.Columns[Arguments.ColumnIndex].Name=="DtVencContas")
{
// return;
var Conta = listaContasPagar[Arguments.RowIndex];
if(Conta.DtVencContas < DateTime.Now)
Arguments.CellStyle.ForeColor = Color.Red;
else
Arguments.CellStyle.ForeColor = Color.Black;
}
}