Solved

Delete child node from Treeview

Posted on 1999-01-18
1
1,394 Views
Last Modified: 2008-03-06
How can I delete easily all the child nodes of a given node?
I have tried something like this:
Set anyNode = myTree.Nodes(myIndex).Child
While anyNode.Children <> 0
  myTree.Nodes.Remove myTree.Nodes(myIndex).Child.Index)
Wend
0
Comment
Question by:pjroy
1 Comment
 
LVL 12

Accepted Solution

by:
jgv earned 20 total points
Comment Utility
Your example works, but you are setting anyNode's index to the first child when it should be set to the parent node. It should read:

Set anyNode = myTree.Nodes(myIndex)
While anyNode.Children <> 0
  myTree.Nodes.Remove (myTree.Nodes(myIndex).Child.Index)
Wend
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now