请老师看看下面的代码,其中:Dim hrs As List(of DataRow) = DataTables("用户表").sqlSelect("group = '" & nb2.name & "'");编译错误:未声明名称“nb2”
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 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("用户表").sqlFind("name = '" & nd1.Name & "'") '这里的代码是不是多余的
If dr Is Nothing Then '不需要在用户表添加不存在的用户
dr = DataTables("用户表").AddNew()
dr("name") = nd1.Name
End If
Dim nms As String
For Each nd2 As WinForm.TreeNode In trv2.Nodes '先添加分组
If nd2.Checked = True Then
Dim hrs As List(of DataRow) = DataTables("用户表").sqlSelect("group = '" & nb2.name & "'")
If hrs.count > 0 Then
For Each hr As DataRow In hrs
nms = nms & "," & hr("group") & "." & hr("name")
Next
End If
End If
Next
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.ParentNode.name & "." & nd2.Name
End If
Next
If nms > "" Then
dr("好友") = nms.Trim(",")
Else
dr("好友") = Nothing
End If