checking treeview nodes

bcbcneau

New member
Joined
Mar 27, 2016
Messages
4
Programming Experience
1-3
I have a tree view with to level nodes : parent and childs , and there are some childs which have the same name , and i want
to do :
if i check any node in treeview , check all the nodes which has the same name of checked node in vb net 2010.
Can you help.
 

IanRyder

Well-known member
Joined
Sep 9, 2012
Messages
1,130
Location
Healing, NE Lincs, UK
Programming Experience
10+
Hi,

Have a look at the TreeView.AfterCheck Event that demonstrates how to recursively check all child nodes of a Parent node that was clicked in the TreeView. All you need to do now to complete your task is to add an If statement at the correct point to decide whether you need to check a particular node or not depending on the current node selected:-

TreeView.AfterCheck Event

Hope that helps.

Cheers,

Ian
 

bcbcneau

New member
Joined
Mar 27, 2016
Messages
4
Programming Experience
1-3
HiI failed to do that , I get this error"can,t evaluate this expression:node.checked=true"Can you help by a simple example if you pleaseThank you
 

IanRyder

Well-known member
Joined
Sep 9, 2012
Messages
1,130
Location
Healing, NE Lincs, UK
Programming Experience
10+
Hi,

The example in the link I provided is a complete code snippet which is just missing your If statement so I am not sure how providing another example will help? Show us the actual code that has caused this error that you have got and we should be able to help you fix that in preparation for solving the complete task.

Cheers,

Ian
 

bcbcneau

New member
Joined
Mar 27, 2016
Messages
4
Programming Experience
1-3
HiI will try myself to solve the problem so I understand more and exceed my skills , after that I will tell you what the results I get , I think the problem is if statement as you told me , so let me tryThank you
 

bcbcneau

New member
Joined
Mar 27, 2016
Messages
4
Programming Experience
1-3
Hi
I am failing in solving the problem and trying to use the code of after select events to color the nodes that have same text with red which is working good but it is not working with after check events, these are two codes
In afterselect:
Dim i as integer
For i =o to treeview1.nodes.count-1
For each y as treenode in treeview1.nodes(i).nodes
If y.isselected then
Y.forecolor=color.red
Dim n as integer
For n= i+1 to treeview1.nodes.count-1
For each z as treenode in treeview1.nodes(n).nodes
If z.text=y.text then
Z.forecolor=color.red
End if
Next
Next
End if
Next
Next


In aftercheck :
Dim i as integer
For i =0 to treeview1.nodes.count-1
For each y as treenode in treeview1.nodes(i).nodes
If y.checked= true then
Dim n as integer
For n=i+1 to treeviewr.nodes.count-1
For each z as treenode in treeview1.nodes(n).nodes
If z.text=y.text then
Z.checked=true
End if
Next
Next
End if
Next
Next

Can you help?
 
Top Bottom