GetNodeAt problem

  • Thread starter Alistair George
  • Start date
A

Alistair George

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.
 
A

Alistair George

Alistair said:
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top