DataColChanged
Select e.DataCol.Name
Case "学校代码", "年级代码", "班级代码"
If e.DataRow.IsNull("学校代码") OrElse e.DataRow.IsNull("年级代码") OrElse e.DataRow.IsNull("班级代码") Then
e.DataRow("编号") = Nothing
Else
Dim lb As String = e.DataRow("学校代码") & e.DataRow("年级代码") & e.DataRow("班级代码")
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(编号)","(学校代码+年级代码+班级代码) = '" & lb & "' 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 Select
http://www.foxtable.com/webhelp/scr/2403.htm