Finding the exact C # node

I tried to implement drag and drop in treeview. First I generate the root nodes, and then if I drag any item over the tree, I want to put it under the exact root nodes . I need something like

private void treeView1_DragOver(object sender, DragEventArgs e)
{
TreeNode tNode = FindNodeAtPoint(e.X, e.Y); 
}

so from tNode I can find its root node and can populate it under this parent node.

can someone help me with findNodeAtPoint () function.

private TreeNode FindNodeAtPoint(int x, int y)
        {            
            Point p = new Point(x, y);
            p = PointToClient(p);
            ................
            ................
            ................
        }
+5
source share
2 answers

Try to find this link:

http://support.microsoft.com/kb/307968

I think you need to. especially part of the method GetNodeAt.

+1
source
private TreeNode FindNodeAtPoint(int x, int y)
{            
      Point pt = treeView1.PointToClient(new Point(e.X, e.Y));
      return treeView1.GetNodeAt(pt);
}

Hope this helps

+3
source

All Articles