放到表属性:DataColChanged 事件中
If e.DataCol.Name = "批号" Then
If e.DataRow.IsNull("批号") Then
e.DataRow("生产日期") = Nothing
e.DataRow("到期日") = Nothing
Else
Dim s As String= "20" & e.DataRow("批号")
s= Mid(s,1,4) & "-" & Mid(s,5,2) & "-" & Mid(s,7,2)
e.DataRow("生产日期") =CDate(s)
e.DataRow("到期日") = e.DataRow("生产日期").adddays(7)
End If
End If