1

Im using treeview in asp.net

how can i check if parent contains childnodes in treeview selected node changed event.

2 Answers 2

1

In case you want to look if the parent of the selected node contains other children nodes, it is safe to say

bool ContainsOtherChildren = treeView1.SelectedNode.Parnet.ChildNodes.Count > 1;

since you know that it already has at least one child node (the selected one)

I would however make another check if there is indeed a parent such as

if(treeView1.SelectedNode.Parent != null)
{
   ContainsOtherChildren = treeView1.SelectedNode.Parnet.ChildNodes.Count > 1;
}
Sign up to request clarification or add additional context in comments.

Comments

0

Check All the child pointer values, whether is it NULL or not.

If all child pointer value is NULL , you can ensure that the parent does not have any child.

1 Comment

Sorry , I posting my c logic code. <code> struct tree { int node ; struct tree *left ; struct tree *right; } ; struct *p; if (p->left !=NULL && p->right !=NULL ) Then p will not be having any child. </code>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.