以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  下拉目录树  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=193992)

--  作者:1234567
--  发布时间:2024/10/31 12:44:00
--  下拉目录树

Object reference not set to an instance of an object.

DropDownBox控件打开目录树错误

 

NodeMouseClick

If e.Node.Level = 1 Then
    Dim tr As Row
    Dim dr As DataRow = e.Node.DataRow
    If e.Form.DropTable IsNot Nothing Then
        tr = e.Form.DropTable.Current
    Else
        Dim nm As String = e.Form.DropDownBox.BindingField
        nm = nm.Split(".")(0)
        tr = Tables(nm).Current
    End If
    tr("工序") = dr("工序")
    tr("工步") = dr("工步")
    e.Form.DropDownBox.Value = tr("工步")
    e.Form.DropDownBox.CloseDropdown()
End If


--  作者:有点蓝
--  发布时间:2024/10/31 13:27:00
--  
调试

If e.Node.Level = 1 Then
    Dim tr As Row
msgbox(e.Node.DataRow is nothing)
    Dim dr As DataRow = e.Node.DataRow
    If e.Form.DropTable IsNot Nothing Then
        tr = e.Form.DropTable.Current
    Else
        Dim nm As String = e.Form.DropDownBox.BindingField
        nm = nm.Split(".")(0)
        tr = Tables(nm).Current
    End If
msgbox(tr is nothing)
    tr("工序") = dr("工序")
    tr("工步") = dr("工步")
    e.Form.DropDownBox.Value = tr("工步")
    e.Form.DropDownBox.CloseDropdown()
End If

--  作者:1234567
--  发布时间:2024/10/31 13:42:00
--  

If e.Node.Level = 1 Then
    Dim tr As Row
    msgbox(e.Node.DataRow Is Nothing)          false
    Dim dr As DataRow = e.Node.DataRow
    MessageBox.Show(1) 
    If e.Form.DropTable IsNot Nothing Then
        MessageBox.Show(2)   
        tr = e.Form.DropTable.Current
        MessageBox.Show(3)   
    Else
        Dim nm As String = e.Form.DropDownBox.BindingField
        MessageBox.Show(4)   显示4后,报警 Object reference not set to an instance of an object.
        nm = nm.Split(".")(0)
        MessageBox.Show(5) 
        tr = Tables(nm).Current
        MessageBox.Show(6)
    End If
    msgbox(tr Is Nothing)
    tr("工序") = dr("工序")
    tr("工步") = dr("工步")
    e.Form.DropDownBox.Value = tr("工步")
    e.Form.DropDownBox.CloseDropdown()
End If

--  作者:有点蓝
--  发布时间:2024/10/31 13:53:00
--  
这个控件没有做绑定
--  作者:1234567
--  发布时间:2024/10/31 14:16:00
--  

能否加一个判断,如果控件没有绑定,就执行e.Form.DropDownBox.Value = dr("工步")


--  作者:有点蓝
--  发布时间:2024/10/31 14:23:00
--  
if e.Form.DropDownBox.BindingField > "" then
有绑定
else
无绑定
end if