datacolchanged事件代码
Dim str As String = ""
Select Case e.DataCol.Name
Case "档号构成项目","位数","连接符"
For Each dr As DataRow In e.DataTable.Select("表名 = '" & e.DataRow("表名") & "'")
If dr.IsNull("档号构成项目") = False Then
If dr.IsNull("位数") Then
str &= "isnull(Convert([" & dr("档号构成项目") & "],'System.String'),'')+"
Else
Dim temp = "substring(isnull(Convert([" & dr("档号构成项目") & "],'System.String'),''),1," & dr("位数") & ")"
str &= "substring('" & "".PadLeft(dr("位数"),"0") & "', 1, " & dr("位数") & "-len(" & temp & ")) + " & temp
str &= "+"
End If
If dr.IsNull("连接符") = False Then
str &= "'" & dr("连接符") & "'+"
End If
End If
Next
DataTables(e.DataRow("表名")).DataCols("文件级档号").Expression = str.trim("+")
If Forms("窗口1").opened Then
Forms("窗口1").Controls("TextBox1").Text = DataTables(e.DataRow("表名")).Compute("max(文件级档号)")
End If
End Select