Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

thanks. That set me in the right direction. Appeciate the help