Solved

VB.net problem gathering two points on a TreeView

Posted on 2012-04-04
2
206 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

10 Experts available now in Live!

Get 1:1 Help Now