Foxtable(狐表)用户栏目专家坐堂 → [求助]打开项目提示“未将对象引用设置到对象的实例”


  共有1900人关注过本帖树形打印复制链接

主题:[求助]打开项目提示“未将对象引用设置到对象的实例”

帅哥哟,离线,有人找我吗?
zhangyj
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:109 积分:1008 威望:0 精华:0 注册:2015/11/3 13:58:00
[求助]打开项目提示“未将对象引用设置到对象的实例”  发帖心情 Post By:2016/4/2 12:52:00 [只看该作者]

我创建了一个窗口,窗口中只有有个treeview控件,在窗口afterload事件中加载treeview的数据,窗口属性为停靠。
关闭项目重新打开项目就会提示"未将对象引用设置到对象的实例" , 为什么在项目打开的时候就检查afterload事件呢,这个窗口是在打开关联表时才会open的?
老师们帮忙看看是是哪里错了。

afterload事件:

Dim nd As WinForm.TreeNode
Dim dt As DataTable
Dim sql As String
Dim je1,je2 As Double
Dim ndtext As String
Dim tr As  WinForm.TreeView = e.Form.Controls("TreeView1")

sql = CExp("sele ct * fr om t1 wh ere projectID ='{0}' ",_ProjectID)
dt = Functions.Execute("GetTableBySQL",sql)

tr.StopRedraw()
tr.Nodes.Clear

je2 = dt.compute("sum(g2float)")

tr.ResumeRedraw()

红色部分注释掉就不会提示了,为什么呢?

内部函数:GetTableBySQL
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
cmd.CommandText = Args(0)
dt = cmd.ExecuteReader()
If dt.DataRows.Count >0 Then    
    Return dt
Else
    Return Nothing
End If
[此贴子已经被作者于2016/4/2 13:13:48编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
Hyphen
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:5015 积分:25363 威望:0 精华:0 注册:2015/8/18 9:21:00
  发帖心情 Post By:2016/4/2 15:01:00 [只看该作者]

说明项目打开的时候关联表已经打开了

Dim nd As WinForm.TreeNode
Dim dt As DataTable
Dim sql As String
Dim je1,je2 As Double
Dim ndtext As String
Dim tr As  WinForm.TreeView = e.Form.Controls("TreeView1")

sql = CExp("sele ct * fr om t1 wh ere projectID ='{0}' ",_ProjectID)
dt = Functions.Execute("GetTableBySQL",sql)

tr.StopRedraw()
tr.Nodes.Clear
If dt IsNot Nothing Then
    je2 = dt.compute("sum(g2float)")
End If
tr.ResumeRedraw()

 回到顶部