Solved

Delete child node from Treeview

Posted on 1999-01-18
1
1,417 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
ID: 1469303
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

861 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