473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treeview check change

I'm using a treeview control.
One parent node, several child nodes, several grandchild nodes.
Each of the nodes has a checkbox.

My question, when the user changes the check value of one of the grandchild
nodes to true how do I automatically change that node's parent to check-true
and so on up the tree.....and in reverse if the parent is changed to
check-false how do I cascade that down to each of the child nodes and their
child nodes.

Any help appreciated

Michael Bond
Feb 29 '08 #1
2 3242
On Fri, 29 Feb 2008 12:55:01 -0800, mabond
<ma****@discuss ions.microsoft. comwrote:
>I'm using a treeview control.
One parent node, several child nodes, several grandchild nodes.
Each of the nodes has a checkbox.

My question, when the user changes the check value of one of the grandchild
nodes to true how do I automatically change that node's parent to check-true
and so on up the tree.....and in reverse if the parent is changed to
check-false how do I cascade that down to each of the child nodes and their
child nodes.

Any help appreciated

Michael Bond
Mar 1 '08 #2
Untested code. To modify the parents, use the Parent property.

Dim parent as TreeNode = node.Parent

Do While parent IsNot Nothing Then
parent.Checked = False
parent = parent.Parent
Loop

To go the other way, you need to recurse through all of the children:

CheckChildren(n ode)

Private Sub CheckChildren(n ode As TreeNode)
Dim child as TreeNode = node.FirstNode

Do While child IsNot Nothing Then
child.Checked = True
CheckChildren(c hild)
child = child.NextNode
Loop

End Sub

While that does what you asked, I'm not sure it is what you really
want. If you check a node, all of the children get set. But if you
uncheck one of those children, only the child's parents, grandparents,
etc. will be unchecked, not the child's siblings.
On Fri, 29 Feb 2008 12:55:01 -0800, mabond
<ma****@discuss ions.microsoft. comwrote:
>I'm using a treeview control.
One parent node, several child nodes, several grandchild nodes.
Each of the nodes has a checkbox.

My question, when the user changes the check value of one of the grandchild
nodes to true how do I automatically change that node's parent to check-true
and so on up the tree.....and in reverse if the parent is changed to
check-false how do I cascade that down to each of the child nodes and their
child nodes.

Any help appreciated

Michael Bond
Mar 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
11538
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
1
6676
by: paradox | last post by:
I want to have a TreeView that shows an image on some items, but not all. Basically, if a certain condition is true, a caution icon is placed next to the treeview item. The problem is that, by adding a ImageList to the TreeView, the ImageIndex property of the items in the TreeView defaults to 0. I could put a blank icon in the ImageList and make it the 0 index image, however, this makes an ugly space. Would I have to create my own...
1
3095
by: Aleksey | last post by:
Hi, All! I have a problem with TreeView component. My TreeView consists of two nodes Node1 and Node2. On click of right mouse button TreeView has event. In this event I check wich node is selected. At the start Node1 is selected. But when I do right click on Node2 the selected node remain Node1. It changed only after left click. Q: How can I check on wich node was right click? Or how can I make TreeView to change selected node by node...
2
2415
by: Srinivasa Raghavan | last post by:
Hi I am using ASP Tree View Control to display data in hiearchy fashion.I am having a checkbox next to the TreeView Node.When user checks or unchecks the nodes and click a button i am putting that count in a stringcollection which is in viewstate.The count is wrong after certain checks and click of the button.can any one explain what could be wrong.
1
1730
by: jyoti ranjan | last post by:
i have a ie webcontrols treeview in my application. by default treeview is selecting the first node as selected index. i don't want a default selectednode. how can i get that one . can any body pls respon i nead to catch selected index change of tree nodes. since it is selecting 1st node as default, it is not posting back if i am trying to select the first one. i could not run the code for 1st node selection. any advice would be...
10
2356
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a top border. Is it possible to have more than 1 style at the same level (parent node) when using a SiteMap? I want it to appear something like this and I can only find a way to either have the border on all root nodes or none at all. In...
2
7494
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
3
3470
by: pamelafluente | last post by:
Hi I have some instances of a class: Class Myobject Public Color As Color Public Label As String End Class I need to show these instances on a treeview (which has checked boxes)
3
4701
by: dutsnekcirf | last post by:
I have a treeview control on a custom task pane in Excel. I've enable the ability to use Drag & Drop (by following this how-to) on the treeview to change the order of the nodes. The problem though is if I close the application and then go back in, the nodes are back in the order they were before I had reordered them. Is there a way that I can modify my DragDrop event to permanently change the index of the nodes? Here's my code if you're...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.