GetNodeAt problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alistair George

    #1

    GetNodeAt problem

    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_DragOve r(object sender,
    System.Windows. Forms.DragEvent Args e)
    {
    e.Effect = DragDropEffects .Move;
    Point pt = PointToClient(n ew Point(e.X, e.Y));
    TreeNode targetNode = this.tvNodes.Ge tNodeAt(pt);
    //targetNode always returns null even though its over another node.
  • Alistair George

    #2
    Re: GetNodeAt problem

    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_DragOve r(object sender,
    System.Windows. Forms.DragEvent Args e)
    {
    e.Effect = DragDropEffects .Move;
    Point pt = PointToClient(n ew Point(e.X, e.Y));
    TreeNode targetNode = this.tvNodes.Ge tNodeAt(pt);
    //targetNode always returns null even though its over another node.
    Answer was:
    Point pt = tvNodes.PointTo Client(new Point(e.X, e.Y));
    TreeNode targetNode = tvNodes.GetNode At(pt);
    tvNodes.Selecte dNode = targetNode;

    Comment

    Working...