?
Solved

remove child nodes from it's parent in treeview

Posted on 2001-06-16
7
Medium Priority
?
1,516 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

801 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