以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]选择好友窗口程序报错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=112848)

--  作者:sjx71
--  发布时间:2018/1/4 8:44:00
--  [求助]选择好友窗口程序报错
选择好友窗口中treeview2 的 AfterCheckNode 的代码如下: 运行到dr = DataTables("好友").AddNew()报错,

请老师帮我看看程序有什么问题
谢谢

Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView2")
Dim nd1 As WinForm.TreeNode = trv1.SelectedNode
If nd1.Level = 0 Then
    Return
End If

Dim r As Row
Dim dr As DataRow
If e.Node.ParentNode IsNot Nothing Then \'取消父节点的选中标记,因为选中子节点,就不要选中父节点了
    e.Node.ParentNode.Checked = False
End If
For Each cnd As WinForm.TreeNode In e.Node.Nodes \'取消子节点的选中标记,因为选中父节点,就不要选中子节点了
    cnd.Checked = False
Next

dr = DataTables("好友").Find("员工 = \'" & nd1.Name & "\'")
MessageBox.show(nd1.name)
If dr Is Nothing  Then
    dr = DataTables("好友").AddNew()
MessageBox.show(1)
    dr("员工") = nd1.Name
End If
MessageBox.Show(2)
Dim nms As String
For Each nd2 As WinForm.TreeNode In trv2.Nodes \'先添加分组
    If nd2.Checked Then
        nms  = nms & ",[" &  nd2.Name & "]"  \'分组名用方括号括起来,表示这是一个分组.
    End If
Next
MessageBox.Show(nms)
For Each nd2 As WinForm.TreeNode In trv2.AllNodes \'然后是普通用户
    If nd2.Level = 1 AndAlso nd2.Checked AndAlso nd1.Name <> nd2.Name Then
        nms  = nms & "," &  nd2.Name
    End If
Next
MessageBox.Show(nms)
If nms > "" Then
    dr("好友") = nms.Trim(",")
Else
    dr("好友") = Nothing
End If


图片点击可在新窗口打开查看此主题相关图片如下:无标题.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:无标题2.png
图片点击可在新窗口打开查看



--  作者:有点甜
--  发布时间:2018/1/4 9:50:00
--  

_Identify列你设置成主键、自动递增了没?

 

http://www.foxtable.com/webhelp/scr/1807.htm

 


--  作者:sjx71
--  发布时间:2018/1/4 9:57:00
--  
我已经设置成了主键了 


图片点击可在新窗口打开查看此主题相关图片如下:无标题3.png
图片点击可在新窗口打开查看


--  作者:有点甜
--  发布时间:2018/1/4 10:25:00
--  

设置成自动递增,如 2楼。


--  作者:sjx71
--  发布时间:2018/1/4 11:08:00
--  
设置成自动递增就好了,谢谢甜老师