1、设置表的DataColChanged事件代码,以便根据生产日期和到期天数,计算出到期日期:
Select Case e.DataCol.Name
Case "生产日期","保质天数"
If e.DataRow.IsNull("生产日期") Then
e.DataRow("到期日期") = Nothing
Else
e.DataRow("到期日期") = e.DataRow("生产日期").AddDays(e.DataRow("保质天数"))
End If
End Select
2、设置表的DrawCell事件代码,标出10天内即将到期的产品:
If e.col.Name = "到期日期" Then
If e.Row.IsNull("到期日期") = False
If e.Row("到期日期") < Date.Today.AddDays(10) Then
e.Style = "到期"
End If
End If
End If