tags:

views:

499

answers:

1

Hi there

I m working on windows project and using c#. I want to catch treeview selected node which i click that by right click.

I'm writing tvlocation.SelectedNode.Index

but it return only Root Node's index.

Thanks for your helps...

+2  A: 

If you are looking to identify the node that was clicked on, then handle the NodeMouseClick event, as follows:

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
    if (e.Button == MouseButtons.Right)  
    {  
        MessageBox.Show(string.Format("Node clicked: {0}", e.Node.Text));  
    }  
}

You could select the node programatically here, if you need that too.

dommer