以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 未将对象引用设置到对象的实例 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=184688) |
-- 作者:lisangyu -- 发布时间:2022/12/22 15:14:00 -- 未将对象引用设置到对象的实例 afterload: Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1") tr.BuildTree("字典", "公司名称|部门", "", "序号") tr.ExpandAll() For Each nd As WinForm.TreeNode In tr.AllNodes If nd.Level = 0 Then nd.Ic ElseIf nd.level = 1 Then nd.Ic End If Next \'tr.StopRedraw \'\'\'\'建立目录树和节点的图标 \'\'\' For Each nd As WinForm.TreeNode In tr.AllNodes Select Case nd.Level Case 0 Dim n As Integer = DataTables ("用户信息管理表").Compute("Count([username])", "一级架构 = \'" & nd.Text & "\'") If n = 0 Then nd.text = nd.Text Else nd.Text = nd.text & "(" & n & ")" End If Case 1 Dim n As Integer = DataTables ("用户信息管理表").Compute("Count([username])", "部门 = \'" & nd.Text & "\'") If n = 0 Then nd.text = nd.Text Else nd.Text = nd.text & "(" & n & ")" End If End Select Next \'tr.ResumeRedraw Dim Filter As String Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行 If e.Node.Text <> "显示所有行" Then Select Case e.Node.Level Case 0 Filter = "[一级架构] = \'" & dr("公司名称") & "\'" Case 1 Filter = "[一级架构] = \'" & dr("公司名称") & "\' And [部门] = \'" & dr("部门") & "\'" End Select End If Tables("账号设置_table1").Filter = Filter \'\'\'\' button 的click: Dim tr As WinForm.TreeView Dim nd As WinForm.TreeNode tr = e.Form.Controls("TreeView1") nd = tr.SelectedNode If nd IsNot Nothing Then Dim pattern As String = "[^\\u4e00-\\u9fa5]" Dim txt = nd.Text Dim str = System.Text.RegularExpressions.Regex.Replace(txt , pattern , "") With Tables("用户信息管理表") Dim r As Integer r = .FindRow("[username] is null") \'从第一行开始查找 If r >= 0 Then \'如果找到的话 MessageBox.Show("不能重复创建空行!", "提示") Else \'If Tables ("账号设置_table1").Current IsNot Nothing Then \'副本表当前行不能为空,不然双击后,当前副本表行为空,选择根目录创建用户信息就报错了 Dim tab As WinForm.TabControl = e.Form.Controls("TabControl1") tab.SelectedIndex = 1 \'\'显示第一个页面 Dim dr As Row = Tables("用户信息管理表").addnew If nd.Level = 0 Then dr("一级架构") = str ElseIf nd.Level = 1 Then Dim txt1 = nd.ParentNode.Text Dim str1 = System.Text.RegularExpressions.Regex.Replace(txt1 , pattern , "") dr("一级架构") = str1 dr("部门") = str End If If Tables("用户信息管理表").Current IsNot Nothing Then Dim max As String Dim xh As Integer max = DataTables("用户信息管理表").Compute("Max(序号)") If max > "" Then \'如果存在最大编号 xh = max + 1 \'获得最大编号的后三位顺序号,并加1 Else xh = 1 \'否则顺序号等于1 End If Tables("账号设置_table1").Current("序号") = xh End If \'’自动加序号排序 End If \' End If End With Else With Tables("用户信息管理表") Dim r As Integer r = .FindRow("[username] is null") \'从第一行开始查找 If r >= 0 Then \'如果找到的话 MessageBox.Show("不能重复创建空行!", "提示") Else Tables("用户信息管理表").addnew If Tables("用户信息管理表").Current IsNot Nothing Then Dim max As String Dim xh As Integer max = DataTables("用户信息管理表").Compute("Max(序号)") If max > "" Then \'如果存在最大编号 xh = max + 1 \'获得最大编号的后三位顺序号,并加1 Else xh = 1 \'否则顺序号等于1 End If Tables("用户信息管理表").Current("序号") = xh End If \'’自动加序号排序 End If End With End if \'\'\'\' 蓝总:下午好! 先双击目录树1级节点,对tables(“用户信息管理表”)的副本表Tables ("账号设置_table1")进行筛选,使得副本表当前行为空,再选中目录树根节点0,点击button按钮创建用户,就提出报错了“未将对象引用设置到对象的实例” |
-- 作者:有点蓝 -- 发布时间:2022/12/22 15:21:00 -- 调试技巧:http://www.foxtable.com/webhelp/topics/1485.htm,看哪一行代码出错 |
-- 作者:lisangyu -- 发布时间:2022/12/22 16:45:00 -- 找到了,每次都忘记了用这个技巧,以为能直接看到,哈哈,代码有点乱,陷进去了。谢谢! |