Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

remove child nodes from it's parent in treeview

Posted on 2001-06-16
7
Medium Priority
?
1,531 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 40 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

618 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