Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
GetNodeFromPoint brings back wrong node
posted

I'm getting some strange behaviour when getting a node back using GetNodeFromPoint().

It's bringing back the wrong node.  Here is the result of two commands I typed into the immediate window to prove the point...

? pointInTree
{X = 79 Y = 335}
    IsEmpty: false
    X: 79
    Y: 335

? this.Tree.GetNodeFromPoint(pointInTree).Bounds
{X = 1 Y = 301 Width = 479 Height = 20}
    Bottom: 321
    Height: 20
    IsEmpty: false
    Left: 1
    Location: {X = 1 Y = 301}
    Right: 480
    Size: {Width = 479 Height = 20}
    Top: 301
    Width: 479
    X: 1
    Y: 301

As you can see the Point I passed in is not within the resulting node.  The resulting node goes from a Y of 301 to 321.  The point I passed in has a Y of 335 which would be the node underneath the one I got back.

Under what circumstances could this method bring back the wrong node?

Thanks,

 

Paul

 

Parents
No Data
Reply
  • 30
    posted

    After further investigation the node being returned is the correct node. 

    The problem is that the .Bounds.Y coordinates for the node does not take into account any column headers displayed in the TreeView.  So the reported Y value is less that it should be, the difference being the height of all the column headers displayed above it. 

    I'm using a pretty old version though (7.3.20073.38).  Maybe this has been changed in later versions.

    I've used the UltraTreeNode.UIElement.Rect property instead and that is correct.

     

    Paul

Children