我创建了一个窗口,窗口中只有有个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编辑过]