Solved

remove child nodes from it's parent in treeview

Posted on 2001-06-16
7
1,481 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Set a default value to Null 1 19
MS Access, hourly employee status 8 40
Sharepoint list to Access database 9 42
MS Access How can I complete my Max, Group by query? 13 22
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

685 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