Assuming this is WinForms, and you are using the Microsoft TreeView:
This is very easy:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
currentNode = e.Node;
if (currentNode .Parent != null)
{
}
}
The default behavior of the MS TreeView
is to change the currently selected TreeNode when the Arrow keys are used. Not only are the Up/Down keys supported, but the Left/Right keys "do the right thing" to expand, or collapse, a current Node with Child Nodes ... without, of course, changing the SelectedNode.
Of course, using this technique does not discriminate between an Up/Down move in the TreeView: perhaps that something you need to do ?