以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教删除行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=188635) |
-- 作者:hbhb -- 发布时间:2023/10/7 21:01:00 -- 请教删除行 大师:下面的代码删除800多行为何要14多秒? SystemReady = False Try 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 & "秒") 有何办法提高效率? |
-- 作者:hbhb -- 发布时间:2023/10/7 21:03:00 -- Dim tbb29 As WinForm.Table = Forms("frm").Controls("Table29") Dim tbb As Table tbb = tbb29.Table Dim st As Date = Date.Now SystemReady = False Try 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 & "秒") |
-- 作者:有点蓝 -- 发布时间:2023/10/7 21:12:00 -- 我测试不到1秒,请上传实例测试 |