Solved

VB.net problem gathering two points on a TreeView

Posted on 2012-04-04
2
212 Views
Last Modified: 2012-08-14
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
Comment
Question by:murbro
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37805436
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
 

Author Closing Comment

by:murbro
ID: 37806264
thanks. That set me in the right direction. Appeciate the help
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now