R
RogerWhitfield
Guest
I have been trying this for ages and just can't get it.
I want to create a Treeview from a datatable in the following structure:-
Level1 Level2 Level3 Level 4
Network, Wireless, Access Point
Network, Wireless, Wireless, Access Point
etc
Now the problem is that when I search to see if a node exists using
If TreeView1.Nodes.Find(l1, True).Length = 0 Then
Then I get results from the entire tree so as shown above it will fail to add Wireless at level 2 as it exists at level 3, If I set the search to not search all children then it only searches level 1, which is fine for level 1 but what I really need to do is set a search to look for duplicates at the level i'm creating nodes at.
level1
Search all level 1 nodes for name and if it exists don't insert
Level 2
Search all level 3 nodes for name and if it exists don't insert
Level 3
Search all level 3 nodes for name and if it exists don't insert
I guess I need some way to set the node at which I'm working but I just cant seem to find any way to do this. My existing code is:-
Dim searchChildren As Boolean = False
Dim l1 As String = ""
Dim l2 As String = ""
Dim l3 As String = ""
With TreeView1
If TreeView1.Nodes.Find(l1, searchChildren).Length = 0 Then
.Nodes("0").Nodes.Add(l1, l1)
End If
If TreeView1.Nodes.Find(l2, searchChildren).Length = 0 Then
.Nodes("0").Nodes(l1).Nodes.Add(l2, l2)
End If
If TreeView1.Nodes.Find(l3, searchChildren).Length = 0 Then
.Nodes("0").Nodes(l1).Nodes(l2).Nodes.Add(l3, l3)
End If
End With
I am at a loss any help you could give would be very much appreciated.
Thanks.
Continue reading...
I want to create a Treeview from a datatable in the following structure:-
Level1 Level2 Level3 Level 4
Network, Wireless, Access Point
Network, Wireless, Wireless, Access Point
etc
Now the problem is that when I search to see if a node exists using
If TreeView1.Nodes.Find(l1, True).Length = 0 Then
Then I get results from the entire tree so as shown above it will fail to add Wireless at level 2 as it exists at level 3, If I set the search to not search all children then it only searches level 1, which is fine for level 1 but what I really need to do is set a search to look for duplicates at the level i'm creating nodes at.
level1
Search all level 1 nodes for name and if it exists don't insert
Level 2
Search all level 3 nodes for name and if it exists don't insert
Level 3
Search all level 3 nodes for name and if it exists don't insert
I guess I need some way to set the node at which I'm working but I just cant seem to find any way to do this. My existing code is:-
Dim searchChildren As Boolean = False
Dim l1 As String = ""
Dim l2 As String = ""
Dim l3 As String = ""
With TreeView1
If TreeView1.Nodes.Find(l1, searchChildren).Length = 0 Then
.Nodes("0").Nodes.Add(l1, l1)
End If
If TreeView1.Nodes.Find(l2, searchChildren).Length = 0 Then
.Nodes("0").Nodes(l1).Nodes.Add(l2, l2)
End If
If TreeView1.Nodes.Find(l3, searchChildren).Length = 0 Then
.Nodes("0").Nodes(l1).Nodes(l2).Nodes.Add(l3, l3)
End If
End With
I am at a loss any help you could give would be very much appreciated.
Thanks.
Continue reading...