XtraGrid(DevExpress) 比较 VB.net 中的 Date Installed 列和 Date Expired 列

问题描述 投票:0回答:1

我只想问是否可以比较 xtragrid gridView1.Columns("DateInstalled") 和 Date.today?

这是我的代码,它对我不起作用:

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

输出是,如果 Date.Today 大于 column("DateExpired"),它会用高亮填充整行,表示它已过期。

真诚的,

vb.net devexpress xtragrid
1个回答
0
投票

试试这个:

   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
© www.soinside.com 2019 - 2024. All rights reserved.