Re: C# Treeview nodes help
Map the NodeClick event of the treeview, when clicked... check the node.text values using Parent and Nodes properties as required to get values up and down the family tree relative to that node...
Code:
private void onNodeClick(object sender, TreeNodeMouseClickEventArgs e)
{
string selectedValue = e.Node.Text; // selected (clicked) node
string childOfSelectedValue = e.Node.Nodes[0].Text; // 1st child of selected
string parentOfSelectedValue = e.Node.Parent.Text; // parent of selected
}
If you wanted the grand parent...
Code:
e.Node.Parent.Parent.Text;
etc....
Re: C# Treeview nodes help
Note: You'll want to do some checking of course, to make sure child nodes and parent nodes exist and have values before trying to access them...