Solved

remove child nodes from it's parent in treeview

Posted on 2001-06-16
7
1,443 Views
Last Modified: 2012-06-27
hi,

how can i remove all of the childs of one parent node
in treeview.

thanks

nima,
0
Comment
Question by:Mohamadi
  • 3
  • 2
  • 2
7 Comments
 
LVL 7

Expert Comment

by:Nosterdamus
ID: 6199691
Hi nima,

For a sample procedure to remove all nodes from a TreeView ActiveX control, please read this MS article (How to Remove All Nodes from TreeView Control):
http://support.microsoft.com/support/kb/articles/Q172/2/86.asp?LN=EN-US&SD=gn&FR=0&qry=treeview&rnk=15&src=DHCS_MSPSS_gn_SRCH&SPR=ACC

To fill a TreeView ActiveX control recursivley, please read this MS article (Sample Procedure to Fill a TreeView Control Recursively):
http://support.microsoft.com/support/kb/articles/Q167/3/09.ASP?LN=EN-US&SD=gn&FR=0&qry=treeview&rnk=5&src=DHCS_MSPSS_gn_SRCH&SPR=ACC

If you are running Access 2000, then read MS Article (ACC2000: How To Fill a TreeView Control Recursively):
http://support.microsoft.com/support/kb/articles/Q209/8/91.ASP?LN=EN-US&SD=gn&FR=0&qry=treeview&rnk=18&src=DHCS_MSPSS_gn_SRCH&SPR=ACC

Hope this helps,

Nosterdamus
0
 

Author Comment

by:Mohamadi
ID: 6200414
Hi
that was great, this exapmle shows how to remove all nodes from tree view, but i want to delete just childs of one node.

please help me!
0
 
LVL 7

Accepted Solution

by:
Nosterdamus earned 10 total points
ID: 6201483
Hi Mohamadi,

Each node in a tree is actually a programmable Node object, which belongs to the Nodes collection. As in other collections, each member of the collection has a unique Index and Key property which allows you to access the properties of the node. For example, the code below uses the Index of a particular node ("7") to set the Image and Text properties:

tvwMyTree.Nodes(7).Image = "closed"
tvwMyTree.Nodes(7).Text = "IEEE"

However, if a unique key, for example "7 ID" had been assigned to the node, the same code could be written as follows:

tvwMyTree.Nodes("7 ID").Image = "closed"
tvwMyTree.Nodes("7 ID").Text = "IEEE"


Therefore, to delete a node from the collection (say "7 ID"), you should use:

tvwMyTree.Nodes("7 ID").Delete
or
tvwMyTree.Nodes(7).Delete


Moreover, I think that you should read http://msdn.microsoft.com/library/default.asp?URL=/library/devprods/vs6/vbasic/vbcon98/vbconusingtreeviewcontrol.htm for more information and Tip on using the TreeView ActiveX control.

Hope this helps,

Nosterdamus
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Mohamadi
ID: 6204659
Hi

thanks for your help, but you may know that in Delphi Nodes of treeview has builtin ability to remove all of children from itself(method name is TNode.DeleteChildren).I mean that is there any method like that in TreeView in Access2000?

thanks
nima,
0
 
LVL 7

Expert Comment

by:Nosterdamus
ID: 6205784
Hi Mohamadi,

Unfortunatly, I'm not familiar with Delphi.
The only way that I can think of, to allow you delete a banch of nodes at once (according to their parent) is using some kind of loop to examine the parent name (or ID), and if it meats your criteria, then delete the node.

Hope this helps,

Nosterdamus
0
 

Expert Comment

by:amp072397
ID: 6742551
Mohamadi:

You've logged in recently. Please come back and give Nost' the feedback he/she deserves.

thanks!
amp
community support moderator
0
 

Expert Comment

by:amp072397
ID: 6758965
Points to Nost'.
amp
community support moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 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

18 Experts available now in Live!

Get 1:1 Help Now