tags:

views:

498

answers:

1

I have the following function (that is incorrect):

private void TreeView_DragDrop(object sender, DragEventArgs e)
{
    TreeNode CurrentNode = 
        TreeView.GetNodeAt(e.X - this.Left - NotesView.Left, 
                           e.Y - this.Top - NotesView.Top);
    // [snip]...
}

But this is incorrect because it doesn't take into account the forms decorations... I'm sure there has to be a better way to do this other than hard coding it (which'll be wrong anyway, depending on several things such as Vista vs XP vs Win2k), but I can't find it.

+3  A: 

You can use:

 Point clientPoint = TreeView.PointToClient( new Point( e.X, e.Y ) );

to get relative coordinates.

Dr Spack