datacolchanged事件
If e.DataCol.name = "第一列" Then
Dim bh As String = e.DataRow("第一列")
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(第二列)","第二列 like '" & bh & "-%' and [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.length+1)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("第二列") = bh & Format(idx,"-000")
End If