If e.DataTable.AllowEdit = True Then
Dim apc As Table = Tables("生产工单_pc")
Dim trv As WinForm.TreeView = e.Form.Controls("glist")
trv.StopRedraw
apc.StopRedraw
Select Case e.DataCol.Name
Case "选中"
If e.NewValue = True Then
e.DataRow("排产张数") = e.DataRow("未排产")
Else
e.DataRow("排产张数") = 0
End If
Case "排产张数"
If e.DataRow.IsNull("单号") Then
e.DataRow("未排产") = e.DataRow("订单明细_排单") - e.DataRow("已排产") - e.DataRow("排产张数")
Else
e.DataRow("未排产") = e.DataRow("订单明细_订单") - e.DataRow("已排产") - e.DataRow("排产张数")
End If
If e.DataRow("未排产") < 0 Then
e.DataRow("未排产") = 0
End If
e.DataRow("排单库存平方") = e.DataRow("排产张数") * e.DataRow("单张库存平方")
trv.BuildTree(e.DataTable, "品名|规格","选中 = 1")
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim zl As String = nd.DataRow("种类")
Dim gg As String = nd.DataRow("规格")
Select Case nd.Level
Case 0
nd.Text = nd.text & " (" & e.DataTable.Compute("Sum(排产张数)","种类 = '" & zl & "'and 选中 = 1") & "张)" & " /" & format(e.DataTable.Compute("Sum(排单库存平方)","种类 = '" & zl & "'and 选中 = 1"),"0") & " 平方"
Case 1
nd.Text = nd.text & " (" & e.DataTable.Compute("Sum(排产张数)","规格 = '" & gg & "'and 选中 = 1") & "张)"
End Select
Next
apc.Sort = "选中 DESC"
End Select
apc.ResumeRedraw
trv.ExpandAll
trv.ResumeRedraw
End If
老师,关于这段代码 执行效率很低,因为一次选中的行最少都有几十行,下面 TreeView 控件仅需要选中结束后刷新一次即可,但是每次都会跟着计算刷新,效率非常低,是否有什么办法解决呢?