Solved

remove child nodes from it's parent in treeview

Posted on 2001-06-16
7
1,494 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 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