datacolchanged事件
Select e.DataCol.Name
Case "第二列"
If e.DataRow.IsNull("第二列") Then
e.DataRow("第一列") = Nothing
Else
Dim lb As String = getpinyin(e.DataRow("第二列"),1)
If e.DataRow("第一列").StartsWith(lb) = False '如果单据第一列前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(第一列)","第二列 = '" & e.DataRow("第二列") & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该第二列的最大第一列
If max > "" Then '如果存在最大第一列
idx = CInt(max.Substring(lb.length)) + 1 '获得最大第一列的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("第一列") = lb & Format(idx,"0000")
End If
End If
End Select