选择好友窗口中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
