可以在
DataRowAdding
事件中:
Dim T1,T2 As String
T1 = "MQ" & Format(Date.today,"yyMMdd")
T2 = "[客户编码] like '" & T1 & "*'and "
T2 = T2 & "[_Identify] < " & e.DataRow("_Identify")
Dim dr As DataRow = e.DataTable.Find(T2,"_Identify DESC")
If dr Is Nothing Then
e.DataRow("客户编码") = T1 & "0001"
Else
Dim n As Integer = Cint(Right(dr("客户编码"),4))+1
e.DataRow("客户编码") = T1 & Format(n,"0000")
End If