代码,DataColchanged
If e.DataCol.Name = "时间" Then
If e.DataRow.IsNull("时间") Then
e.DataRow("编号") = Nothing
Else
Dim bh As String = "XF" & Format(e.DataRow("时间"),"yyyyMMdd") '取得编号的10位前缀
If e.DataRow("编号").StartsWith(bh) = False '如果编号的前10位不符
Dim max As String
Dim 编号x As Integer
max = e.DataTable.Compute("Max(编号)","编号 like '" & bh & "*' ") '取得该天的最大编号
If max > "" Then '如果存在最大编号
编号x = CInt(max.Substring(10,4)) + 1 '获得最大编号的后四位顺序号,并加1
Else
编号x = 1 '否则顺序号等于1
End If
e.DataRow("编号") = bh & Format(编号x,"0000")
End If
End If
End If