-
Hiding parent nodes
Hello everybody,
I have a treeview control in my application and a hierarchy of sub-nodes. Application works on rights. If user doesnt have rights to see a particular screen, the treeview node hides and user doesn't know there is some option of this screen in the application. Suppose I have a parent treeview node "Administrator", with a sub-node "Setup". "Setup" contains three more nodes, "Backup","Restore", "Reset". If user doesn't have rights to see all three Backup, Restore and Reset screens, these options hide but user can see "Setup" node and "Administrator" node.
I need to traverse all the nodes and if all the child nodes of a node are not present(treeNode.Remove()), I want to hide/remove the parent node of that sub-nodes.
Any ideas ??
Thanks
-
Re: Hiding parent nodes
I don't think that is possible.
You will have to rebuild the treenodes in this scenario, and make the Setup node a parent node.
If you find a way to do this, be cool and post it here. I would be curious to see how this can be done, allthough I doubt you can.
-
Re: Hiding parent nodes
I have done the same thing with Menus, but there I was hiding the menu items not removing. Here in treeview, I already have removed the nodes that are not seen to the user. If somehow I know whether a node has child then this can be done easily.
-
Re: Hiding parent nodes
why not count the node's children in code, and act accordingly?
did not use it for a long time (tester now), but just search around, I know I found the help here on the forum
-
Re: Hiding parent nodes
How ?? Do we have some property or I have to loop through the nodes recursively ?
-
Re: Hiding parent nodes
i wrote a similar program. I created a new treeNode class from TreeNode and addes properties to indicate what TYPE of node it is..ie Setup, Application, File, etc...
When the tree starts to build, the nodes react accordingly on their own depending on what type it is. If the user is an admin, all nodes were visible, if the user is say, a backup user, certain nodes hide themselves.