老师您好! 我有一个表ddpsb,要改变编号规则,就是当年年份后两位+行号,可是我改变后,每次操作增加行时,系统自动关闭退出。不知道如何处理。谢谢指教!
原来的格式:20240728-005
我后来改成这样的格式:24-行号~
现在的代码:
Dim dl As Date = Date.Today
Dim y As Integer = dl.Year
Dim bh As String = Format(dl, "yy")
e.DataRow("zzh") = bh & "-" & e.DataRow("_Identify")
e.DataRow.save
老师我把代码改了一下,还是不执行,一旦输入数据,就自动关闭系统了。您再帮我看一下,谢谢!
Dim dl As Date = Date.Today
Dim y As Integer = dl.Year
'Dim dr As DataRow = e.DataRow
If e.DataCol.Name = "zzh" Then
Dim bh As String = Format(dl, "yy")
e.DataRow("zzh") = bh & "-" & e.DataRow("_Identify")
e.DataRow.save
End If
代码放到datarowadded事件
Dim dl As Date = Date.Today
Dim bh As String = Format(dl, "yy")
e.DataRow.save
e.DataRow("zzh") = bh & "-" & e.DataRow("_Identify")
放到datarowadded事件中
Dim dl As Date = Date.Today
Dim bh As String = Format(dl, "yy")
e.DataRow.save
e.DataRow("zzh") = bh & "-" & e.DataRow("_Identify")
增加新行,zzh还是空白没有填充。