Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

VB.net problem gathering two points on a TreeView

Hi

I am using the following code to gather the coordinates to draw a line between the point
at which my mouse goes down on a TreeView and the point at which the drag is dropped.
Even though the two points are very close I get the following variable values. What am I doing wrong? How can I change the code?

X_From = 91
Y_From = 42
e. X = 1625
e.Y = 466

    Private Sub TreeView_From_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView_From.MouseDown
        'This picks up the node when the mouse goes down
        'If there is no node then the variable reflects this and short citcuits code on the drop
        Dim oNode As String
        Dim oParentNode As String

        oNode_on_MouseDown = TreeView_From.GetNodeAt(e.X, e.Y)
        If oNode_on_MouseDown Is Nothing Then
            '
        Else
            oNode = oNode_on_MouseDown.Text
            oParentNode = oNode_on_MouseDown.Parent.Text
           
            X_From = e.X
            Y_From = e.Y
        End If

    End Sub

    Private Sub TreeView_From_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TreeView_From.DragDrop

                If oNode_on_MouseDown IsNot Nothing Then 'GET FROM NODE ON MOUSEDOWN

                    oTo_Point = Me.TreeView_From.PointToClient(New Point(e.X, e.Y))
                    'Add to the join


                    oDrawLine()
                End If

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
0
Murray Brown
Asked:
Murray Brown
1 Solution
 
CodeCruiserCommented:
What comes back if you change

oTo_Point = Me.TreeView_From.PointToClient(New Point(e.X, e.Y))

to

oTo_Point = New Point(e.X, e.Y)
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks. That set me in the right direction. Appeciate the help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now