AfterEditNode 代码改一下,利用FIND查找是否已经存在节点
If e.NewText = "" Then
e.Cancel = True
Return
End If
Dim pth() As String = e.Node.FullPath.Split("\")
Dim dr As DataRow
Select Case e.node.Level
Case 0
dr= DataTables("表A").Find("大类 = '" & e.NewText & "'")
If dr Is Nothing Then
DataTables("表A").ReplaceFor("大类",e.NewText,"大类 = '" & pth(0) & "'")
Else
MessageBox.show("已存在该节点")
e.Cancel=True
End If
Case 1
dr= DataTables("表A").Find("大类 = '" & pth(0) & "' And 二类 = '" & e.NewText & "'")
If dr Is Nothing Then
DataTables("表A").ReplaceFor("二类",e.NewText,"大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "'")
Else
MessageBox.show("已存在该节点")
e.Cancel=True
End If
Case 2
dr= DataTables("表A").Find("大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "' And 三类 = '" & e.NewText & "'")
If dr Is Nothing Then
DataTables("表A").ReplaceFor("三类",e.NewText,"大类 = '" & pth(0) & "' And 二类 = '" & pth(1) & "' And 三类 = '" & pth(2) & "'")
Else
MessageBox.show("已存在该节点")
e.Cancel=True
End If
End Select
e.Node.Name = e.NewText