troubleshooting Question

Loop through TreeView nodes and deleted all checked except index 0. How?

Avatar of donniedarko801
donniedarko801 asked on
Visual Basic.NET
12 Comments1 Solution914 ViewsLast Modified:
Hello Experts,

I can't figure out what I'm doing wrong.

I have a TreeView with CheckBox mode set to True and with nothing but Parent Nodes. After checking the first node and a few other random ones I want to loop through this TreeView, and Remove all nodes except the one at Index 0.

Here's my code. A slight variation of it does work to set the Node-Checkbox-Values to False but not to Remove the same.

For Each ctl As TreeNode In TreeView1.Nodes
                    If ctl.Index <> 0 And ctl.Checked = True Then
                    End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros