大师:下面的代码删除800多行为何要14多秒?Dim hjh As New List(Of Row)
For n As Integer = tbb.Rows.Count - 1 To 0 Step - 1
If tbb.Rows(n).DataRow.RowState = DataRowState.Added Then
' tbb.Rows(n).Delete
hjh.Add(tbb.Rows(n))
End If
Next
For Each r As Row In hjh
r.Delete
Next
Catch ex As Exception
MessageBox.Show("追加数据失败")
End Try
SystemReady = True
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
有何办法提高效率?
Dim tbb29 As WinForm.Table = Forms("frm").Controls("Table29")
Dim tbb As Table
tbb = tbb29.Table
Dim st As Date = Date.Now
Dim hjh As New List(Of Row)
For n As Integer = tbb.Rows.Count - 1 To 0 Step - 1
If tbb.Rows(n).DataRow.RowState = DataRowState.Added Then
' tbb.Rows(n).Delete
hjh.Add(tbb.Rows(n))
End If
Next
For Each r As Row In hjh
r.Delete
Next
Catch ex As Exception
MessageBox.Show("追加数据失败")
End Try
SystemReady = True
MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")