XtraGrid(DevExpress) Comparing Date Installed column and Date Expired column in VB.net

40 views Asked by At

I just want to ask if it is possible to comparing an xtragrid gridView1.Columns("DateInstalled") and Date.today?

this is my code and it won't work for me:

Private Sub GridView1_RowCellStyle(sender As Object, e As Views.Grid.RowCellStyleEventArgs) Handles GridView1.RowCellStyle
        Dim dateExp As Date = Date.Parse(GridView1.Columns("DateExpired"))

        If dateExp < Date.Today Then
            e.Appearance.BackColor = Color.Red
        End If
    End Sub

The output is, if the Date.Today greater than column("DateExpired"), it will fill the entire row with highlighted represent that it is expired.

Sincerely,

1

There are 1 answers

0
Abdellah OUMGHAR On BEST ANSWER

Try this :

   Private Sub GridView1_RowCellStyle(sender As Object, e As DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs) Handles GridView1.RowCellStyle

        Dim dateExp As Date = Date.Parse(GridView1.GetRowCellValue(e.RowHandle, "DateExpired"))

        If dateExp < Date.Today Then
            e.Appearance.BackColor = Color.Red
        End If

    End Sub