check parent when child is checked in treeview
-
hi all when i check the child node of a treeview it will automatically check the parent node of that child node. can some one tell me how can i do that i am trying to do that but the recursive procedure (that will check all the child nodes when the parent node is checked) is making it difficult. thanks in advance help everyone
-
hi all when i check the child node of a treeview it will automatically check the parent node of that child node. can some one tell me how can i do that i am trying to do that but the recursive procedure (that will check all the child nodes when the parent node is checked) is making it difficult. thanks in advance help everyone
I don't know exactly what you want but here are a few ideas: when child node is checked and parent noded needs to be checked you can use the parent property of the child node wich will give you its parent node and then you can check that one when a parent node is checked and all child nodes need to be checked you can use the nodes (I think its called like this but not shure) property of the parent wich will give you a collection of nodes, then iterate thru them and check all of them hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.
-
I don't know exactly what you want but here are a few ideas: when child node is checked and parent noded needs to be checked you can use the parent property of the child node wich will give you its parent node and then you can check that one when a parent node is checked and all child nodes need to be checked you can use the nodes (I think its called like this but not shure) property of the parent wich will give you a collection of nodes, then iterate thru them and check all of them hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.
the problem is 1. when all child and parent nodes are unchecked, then , when child node is checked then i need to also check its parent node. thats exactly what i want to do. what i have done 1. when a parent node is checked, all of its child nodes is checked. 2. when a parent node is unchecked, all of its child nodes is unchecked. 3. checks and unchecks all the parent nodes and child nodes with the help of buttons. all these things are using some sort of recursive function and thats cause the problem. i use all that in aftercheck event of treeview any help will be thankfull help everyone
-
the problem is 1. when all child and parent nodes are unchecked, then , when child node is checked then i need to also check its parent node. thats exactly what i want to do. what i have done 1. when a parent node is checked, all of its child nodes is checked. 2. when a parent node is unchecked, all of its child nodes is unchecked. 3. checks and unchecks all the parent nodes and child nodes with the help of buttons. all these things are using some sort of recursive function and thats cause the problem. i use all that in aftercheck event of treeview any help will be thankfull help everyone
eyes2007 wrote:
what i have done 1. when a parent node is checked, all of its child nodes is checked. 2. when a parent node is unchecked, all of its child nodes is unchecked. 3. checks and unchecks all the parent nodes and child nodes with the help of buttons. all these things are using some sort of recursive function and thats cause the problem. i use all that in aftercheck event of treeview
So you were able to do those 3 things?
eyes2007 wrote:
the problem is 1. when all child and parent nodes are unchecked, then , when child node is checked then i need to also check its parent node. thats exactly what i want to do.
to do this you will need to 'override' the aftercheck event of the treeview otherwise it's going to cause problems as you already noticed. the easyst way to do this is with a boolean. when the aftercheck event is fired check if its a child node or not if so put boolean to false and check the parent after this you put the boolean back to true. and then as first check in the aftercheck event you check this boolean if its false you do nothing else you do the code needed. this is probably not the best way to do this but it should work and that's how I would start and see where it gets me. if you have problems with implementing this post the code (or part of the code) in the aftercheck event that way I can have a better picture of what you are doing and what is going on. hope this helps
If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistakes.