Reputation: 25
How can I know if a TreeView has TreeNodes, regardless of whether they are parent or child nodes? I just want to avoid duplication. The pseudo-code looks like:
If TreeView1 has TreeNodes Then
'Remove old ones and create another
'Or Exit to skep creation of new ones
Else
'Create TreeNodes
End Sub
Upvotes: 0
Views: 220
Reputation: 1765
You can check TreeView1.Nodes.Count or you can simply call TreeView1.Nodes.Clear() to ensure it's always clear before you add new ones
Update for more complete answer:
If TreeView1.Nodes.Count = 0 Then
'Remove old ones and create another
'Or Exit to skep creation of new ones
Else
'Create TreeNodes
End Sub
Upvotes: 2