以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]删除行代码运行很慢? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157634) |
-- 作者:2425004926 -- 发布时间:2020/10/23 15:32:00 -- [求助]删除行代码运行很慢? 删除行代码,为何运行时非常慢,要等很长时间 Case "ButtonDelete" \'删除行 .StopRedrawDim drs As List(Of DataRow) drs = .DataTable.Select("[选] = True") If drs.Count = 0 Dim i As Integer Dim i1 As Integer = .TopRow \'最上行位置 Dim i2 As Integer = .BottomRow \'最末行位置 For i = i2 To i1 Step -1 .Rows(i).delete() Next Else For Each dr As DataRow In drs dr.delete() Next End If .ResumeRedraw |
-- 作者:2425004926 -- 发布时间:2020/10/23 15:34:00 -- 还有一行代码,刚忘记了复制 With Tables(e.form.name & "_Table1") End With
|
-- 作者:有点蓝 -- 发布时间:2020/10/23 15:42:00 -- 有多少行数据?表格都有什么表事件? |
-- 作者:2425004926 -- 发布时间:2020/10/23 15:54:00 -- 1000多行 所有表事件 BeforeSelChange事件 If e.OldRange.RowSel <> e.NewRange.RowSel \'如果选择的是不同的行 If e.OldRange.RowSel >= 0 AndAlso e.OldRange.Rowsel < e.Table.Rows.Count Then \'而且原来选择的是一个有效的数据行 Dim r As Row = e.Table.Rows(e.OldRange.Rowsel) \'获得原来选择的行 r.Save() \'保存之 End If End If DrawCell事件 If e.Col.name = "照片名称" And e.Row.Isnull("照片名称") = False Then If Left(e.Row("照片名称"), e.Row("照片名称").LastIndexOf(".")) <> e.Row("档案号") Then e.style = "红" End If ElseIf e.Col.name = "档案号" Then If e.Row.Isnull("档案号") Then e.style = "红" End If ElseIf e.Col.name = "题名" Then If e.Row.Isnull("题名") Then e.style = "红" End If End If DataColChanged事件 If e.DataCol.name = "照片名称" Then
If e.DataRow.Isnull("照片名称") Then e.DataRow("路径") = Nothing e.DataRow("照片宽") = Nothing e.DataRow("照片高") = Nothing e.DataRow("长高比例") = Nothing e.DataRow("高长比例") = Nothing e.DataRow("报表照片宽") = Nothing e.DataRow("报表照片高") = Nothing e.DataRow("版式") = Nothing Else If Forms("照片目录").Controls("TextBoxFile").text > "" Then Dim img As Image = GetImage(Forms("照片目录").Controls("TextBoxFile").text & "\\" & e.DataRow("照片名称")) \'以下没有放在路径为空是因为通过重置列可以更改路径 If img IsNot Nothing Then If e.DataRow.Isnull("路径") Then e.DataRow("路径") = Forms("照片目录").Controls("TextBoxFile").text & "\\" & e.DataRow("照片名称") End If If e.DataRow.Isnull("照片宽") Then e.DataRow("照片宽") = img.Width End If If e.DataRow.Isnull("照片高") Then e.DataRow("照片高") = img.Height End If If e.DataRow.Isnull("长高比例") Then e.DataRow("长高比例") = e.DataRow("照片宽")/e.DataRow("照片高") End If If e.DataRow.Isnull("高长比例") Then e.DataRow("高长比例") = e.DataRow("照片高")/e.DataRow("照片宽") End If If e.DataRow.Isnull("报表照片宽") Then e.DataRow("报表照片宽") = 100 * e.DataRow("照片宽")/e.DataRow("照片高") End If If e.DataRow.Isnull("报表照片高") Then e.DataRow("报表照片高") = 100 End If If e.DataRow("长高比例") < 1 Then e.DataRow("版式") = "竖" ElseIf e.DataRow("长高比例") >= 1 Then e.DataRow("版式") = "横" End If End If End If End If End If |
-- 作者:有点蓝 -- 发布时间:2020/10/23 15:58:00 -- 试试 Case "ButtonDelete" \'删除行 systemready = false .StopRedrawDim cnt as integer = .DataTable.compute("count(选)","[选] = True") If cnt = 0 Dim i As Integer Dim i1 As Integer = .TopRow \'最上行位置 Dim i2 As Integer = .BottomRow \'最末行位置 For i = i2 To i1 Step -1 .Rows(i).delete() Next Else .DataTable.delete("[选] = True") End If .save systemready = true
.ResumeRedraw |
-- 作者:2425004926 -- 发布时间:2020/10/23 16:09:00 -- 这行代码 .DataTable.delete("[选] = True") 显示delete不是DataTable成员
|
-- 作者:有点蓝 -- 发布时间:2020/10/23 16:29:00 -- 自己改改:http://www.foxtable.com/webhelp/topics/0394.htm |
-- 作者:2425004926 -- 发布时间:2020/10/23 16:43:00 -- 好的,非常谢谢! |