-1

Since the TreeView control doesn't provide an event that is raised when a child node is selected on a tree node, I am trying to construct a way in which I can check if the selected child node is a specific child node. I need this to set a display based on the selected child node. It should look something like this:

private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
  TreeNodeCollection ParentNode = treeView1.Nodes;
  if (treeView1.SelectedNode == ParentNode.Node5) //If the selected node is child node 5
  {
    label3.Text = "This is the text for ChildNode5.";
  }
0

1 Answer 1

0

This question has already been answered here:

Why isn't there a selected node changed event

From the answer:

This event does not occur when the node is unselected. To detect this occurrence, handle the Control.MouseUp event and test the TreeNode.IsSelected property.

Not the answer you're looking for? Browse other questions tagged or ask your own question.