Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a treeview with a parent and child node. How do I know that the checked node that I have is a parent node?I am using the CheckedChanged event for treeview.

Thanks,

Franco Cipriano
Posted

Look at its Nodes property - if the collection is empty, it is not a parent...
 
Share this answer
 
Hi,

Give it a try as follows....

C#
if (selectedNode.Parent == null)
{
    MessageBox.Show("The node does not have a parent.");
}


Regards
Sebastian
 
Share this answer
 
Comments
Franco Cipriano 20-Jul-12 5:46am    
do I need to declare 'selectedNode' as TreeNode? sorry, im quite new with asp.net c#..

thanks,
Sebastian T Xavier 20-Jul-12 12:26pm    
Just try Tree1.SelectedNode ....
thank you very much , i got it
 
Share this answer
 
Comments
Deepu S Nair 12-Mar-15 6:38am    
Don't post your comment as solution

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