tags:

views:

54

answers:

2

I was trying to implement drag and drop in treeview . I generate the root nodes first then if I drag any item over the treeview I want to put it under exact root nodes. I need something like

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

so that from tNode I can find it's root node and can populate it under that parent node.

can anybody help me out with findNodeAtPoint() functinoality.

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

Hope this helps

ArsenMkrt
A: 

Try looking at this link:

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

I think it's what you need. especially the part of GetNodeAt method.

Shai Rubinshtein