Tenho uma base de dados com as seguintes tabelas: Data Emissão
e Data Expira
.
Então eu quero que, quando a data do Data expira
for igual ou superior a Data Emissao
, a row
mude de cor para Vermelho
e quando estiver faltando 1 mês para atingir a data mude de cor para Amarelo
.
Meus codigos
Private Sub CadastroDataGridView_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles CadastroDataGridView.CellFormatting
If Me.CadastroDataGridView.Columns(e.ColumnIndex).Name = "DataGridViewTextBoxColumn15" Then
If e.Value IsNot Nothing Then
Dim dgvdate As Date = CDate(e.Value)
If dgvdate < CDate(Now) Then
e.CellStyle.BackColor = Color.Red
e.FormattingApplied = True
Else
e.CellStyle.BackColor = Color.Green
e.FormattingApplied = True
End If
End If
End If
End Sub