Murray Brown
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(By Val sender As Object, ByVal e As System.Windows.Forms.Mouse EventArgs) 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(sen der As Object, e As System.Windows.Forms.DragE ventArgs) Handles TreeView_From.DragDrop
If oNode_on_MouseDown IsNot Nothing Then 'GET FROM NODE ON MOUSEDOWN
oTo_Point = Me.TreeView_From.PointToCl ient(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
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(By
'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.
If oNode_on_MouseDown Is Nothing Then
'
Else
oNode = oNode_on_MouseDown.Text
oParentNode = oNode_on_MouseDown.Parent.
X_From = e.X
Y_From = e.Y
End If
End Sub
Private Sub TreeView_From_DragDrop(sen
If oNode_on_MouseDown IsNot Nothing Then 'GET FROM NODE ON MOUSEDOWN
oTo_Point = Me.TreeView_From.PointToCl
'Add to the join
oDrawLine()
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER