【发布时间】:2010-11-12 20:08:46
【问题描述】:
我正在尝试根据日期列按以下顺序标记网格中的行
- 从今天起 2 天或更长时间 然后是红色
- 当 1 天大时为黄色
- 当 0 天时为绿色
- 当日期在未来时 蓝色
我有以下工作正常,除了未来的日期是绿色而不是蓝色。
Dim myDate As DateTime = CType(grdSummaryView.GetRowCellValue(e.RowHandle, "myDate"), DateTime)
Select Case Now.Subtract(myDate).Days
'2 or more days old then RED FLAG
Case Is >= 2
e.Value = ImageCollection2.Images(3)
Case 1
'1 day old then YELLOW FLAG
e.Value = ImageCollection2.Images(1)
Case 0
'Current day then GREEN FLAG
e.Value = ImageCollection2.Images(0)
Case Else
e.Value = ImageCollection2.Images(4)
End Select
【问题讨论】:
-
天数将返回 0,除非您在未来至少 24 小时?因此,如果它是 2010/08/15 12:30:00 并且您的未来日期是 2010/08/16 0:30:00 那么我相信 TimeSpan 是 -00:12:00:00 等等?
-
我试过 CASE
-
可能......如果是这样的话,只需将 .Date 添加到 myDate 分配和 Select Case 中即可。
-
@Saif,“一天前”是指“前一天”还是“24 小时以上”?