-- 作者:ajie5211
-- 发布时间:2016/8/26 16:39:00
-- [求助]带目录树节点的动态筛选并分页加载
Dim txt As String = e.Form.Controls("过滤值").Text Dim tbl As DataTable = DataTables("tabDIYTable24") Dim sxxm As String = e.Form.Controls("过滤项目").text Dim ftxt As String Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") Dim tb As WinForm.TreeNode = trv.SelectedNode Dim i As Integer = tb.Level If txt = "" And tb.Text <> "所有分类" And i = 0 Then ftxt = "F128" & " = " & tb.Text Else If txt = "" And tb.Text <> "所有分类" And i = 1 Then ftxt = "F128" & " = " & tb.ParentNode.Text & "F126" & " = " & tb.Text Else If txt <> "" And tb.Text <> "所有分类" And i = 0 Then txt = "\'%" & txt & "%\'" For Each cl As DataCol In DataTables("tabDIYTable24").DataCols If cl.Caption = sxxm Then ftxt = cl.Name & " Like " & txt & "F128" & " = " & tb.Text End If Next Else If txt <> "" And tb.Text <> "所有分类" And i = 1 Then txt = "\'%" & txt & "%\'" For Each cl As DataCol In DataTables("tabDIYTable24").DataCols If cl.Caption = sxxm Then ftxt = cl.Name & " Like " & txt & "F128" & " = " & tb.ParentNode.Text & "F126" & " = " & tb.Text End If Next Else If txt <> "" And tb.Text = "所有分类" Then txt = "\'%" & txt & "%\'" For Each cl As DataCol In DataTables("tabDIYTable24").DataCols If cl.Caption = sxxm Then ftxt = cl.Name & " Like " & txt End If Next Else ftxt = "" End If With DataTables("tabDIYTable24") .LoadFilter = ftxt \'一定要清除加载条件 .LoadTop = 15 .LoadPage = 0 .Load() End With
上面代码要么提示F128处语法错误,要么提示未将对像引用设置到对像的实例,求解决方法并简化代码。F128和F126是表tabDIYTable24中的列名。 此主题相关图片如下:qq图片20160826163618.png
|