0

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 

1 Answer 1

2

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.