Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi frind i have a tree view control using first time in my window application, my problem is that if the parent node the the tree view is checked then the user can not able to unckeck the the childe node if he want to uncheck the child node by compulsion uncheck the parent node of the child node first.

Thanks in advance

Rathi
Posted
Comments
Sunasara Imdadhusen 4-May-11 2:29am    
Please provide code snippet!
Sergey Alexandrovich Kryukov 4-May-11 2:32am    
Tag it! Forms, WPF, what?
What is "check"? Selection may be. Or a check box in a node?
--SA

1 solution

Assuming you are using Winforms, handle the BeforeCheck event for the TreeView:
private void myTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e)
    {
    if (e.Node.Parent != null && e.Node.Parent.Checked && e.Node.Checked)
        {
        e.Cancel = true;
        }
    }
This forbids unchecking nodes unless the immediate parent is also unchecked.
If this is not what you are trying to achieve, it is not clear from your question, so please explain what you are trying to achieve more clearly.
 
Share this answer
 
Comments
Parveen Rathi 5-May-11 8:31am    
Thanks sir for reply

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