Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a tree view with the below structure

X
|---X1
|---X2
     |.....X11
     |.....X12
Y
|---Y1
|---Y2
    |.....Y11
    |.....Y12


When I disable for eg, Node Y, I want all the child nodes also should be disabled and the color must become gray.

Can anyone help plz!!
Posted
Updated 26-Apr-15 22:52pm
v2

1 solution

Try this


C#
var node2 = TreeView1.Nodes[1]; // second node
           node2.SelectAction = TreeNodeSelectAction.None;
           foreach (TreeNode node in node2.ChildNodes)
           {
               node.SelectAction = TreeNodeSelectAction.None;
               foreach (TreeNode subnode in node.ChildNodes)
               {
                   subnode.SelectAction = TreeNodeSelectAction.None;

               }
           }
 
Share this answer
 
Comments
Member 10112611 27-Apr-15 5:36am    
Thank you , I tried and this is working.

Can we have client side code for the same?
or instead of loop any option to disable child automatically on parent node disabling- For eg, In case if I don't know the level of child nodes...
Karthik_Mahalingam 27-Apr-15 5:42am    
without looping you cannot disable all nodes in c#
we can try using jquery.
Member 10112611 27-Apr-15 5:47am    
Ok.. Can you help me on Jquery. I am not good at Jquery
Karthik_Mahalingam 27-Apr-15 5:50am    
how will you disable a node?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900