Welcome Guest Search | Active Topics | Members | Log In | Register

GetNodeAt problem Options · View
Alistair George
Posted: Saturday, October 06, 2007 2:49:18 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 02:49:18
Date: Fri, 05 Oct 2007 14:49:18 +1200

tvNodes is a treeview. In one program using exactly the same code, it
provides a selectednode object correctly, however in another using same
code it cannot detect which item is under the cursor.
Any idea why this should not work - I have checked out properties/events
side-by side between both treeview components and they are replicated:

private void tvNodes_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
Point pt = PointToClient(new Point(e.X, e.Y));
TreeNode targetNode = this.tvNodes.GetNodeAt(pt);
//targetNode always returns null even though its over another node.
Alistair George
Posted: Saturday, October 06, 2007 4:08:24 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 04:08:24
Date: Fri, 05 Oct 2007 16:08:24 +1200

Alistair George wrote:
> tvNodes is a treeview. In one program using exactly the same code, it
> provides a selectednode object correctly, however in another using same
> code it cannot detect which item is under the cursor.
> Any idea why this should not work - I have checked out properties/events
> side-by side between both treeview components and they are replicated:
>
> private void tvNodes_DragOver(object sender,
> System.Windows.Forms.DragEventArgs e)
> {
> e.Effect = DragDropEffects.Move;
> Point pt = PointToClient(new Point(e.X, e.Y));
> TreeNode targetNode = this.tvNodes.GetNodeAt(pt);
> //targetNode always returns null even though its over another node.
Answer was:
Point pt = tvNodes.PointToClient(new Point(e.X, e.Y));
TreeNode targetNode = tvNodes.GetNodeAt(pt);
tvNodes.SelectedNode = targetNode;
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.084 seconds.