This may be very easy question but I am thinking of solution for a long while. I need to keep some condition in the if statement stating that the node is the parent node of all in the TreeView control. Please suggest what expression should I keep in the if statement.
if(Condition??) //it is the parent node of all
{
myTreeView.SelectedNode.Nodes.Add(myTreeNode);
}
else
{
myTreeView.SelectedNode.Parent.Nodes.Add(myTreeNode);
}
In the above code I am trying to add a parallel node to the selected node which is working but when I am trying the same code (i.e., myTreeView.SelectedNode.Parent.Nodes.Add(myTreeNode);) to parent node, VS was showing error.(which I know why so I am trying the above code to achieve it)
You can use the
TreeNode.Parentproperty for this: