Solved

VB.net problem gathering two points on a TreeView

Posted on 2012-04-04
2
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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