Solved

VB.net get X position of left of TreeView

Posted on 2012-04-03
7
301 Views
Last Modified: 2012-04-05
Hi. I am trying to gather the X position of the side of m TreeView so that
I can draw a vertical line from just to the right of the left border of the TreeView.
The variable intFrom_X_Axis in the following code gathers this but it isn't really working
Not sure why

    Private Sub TreeView_From_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles TreeView_From.DragEnter
        'See if there is a TreeNode being dragged
        If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", _
            True) Then
            'TreeNode found allow move effect
            'e.Effect = DragDropEffects.Move
            e.Effect = DragDropEffects.All

        Else
            'No TreeNode found, prevent move
            e.Effect = DragDropEffects.None
            Exit Sub
        End If

        intFrom_X_Axis = Me.TreeView_From.Location.X + 20

        oFrom_Point = Me.TreeView_From.PointToClient(New Point(intFrom_X_Axis, e.Y))

    End Sub
0
Comment
Question by:Murray Brown
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37801715
What is the value of Location.X coming back before and after pointtoclient?
0
 

Author Comment

by:Murray Brown
ID: 37801972
It comes back with a value of about 50 when e.X returms 1650
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37802039
That sounds right to me because you are translating it into treeview coordinates (x is 0 at left edge of treeview).
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37802109
What are you drawing on?  By that, I mean what control is the Graphics() associated with?
0
 

Author Comment

by:Murray Brown
ID: 37812544
I am drawing on the TreeView

   Sub oDrawLine()

        Dim Gr As Graphics = Me.TreeView_From.CreateGraphics()
        ' Create pen.

        Dim orangePen As Pen        orangePen = New Pen(Color.DarkOrange, 2)
        'Dim point1 As New Point(10, 10)
        'Dim point2 As New Point(100, 500)
        Gr.DrawLine(orangePen, oFrom_Point, oTo_Point)

    End Sub
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37812883
Try:

        Dim ptX As Point = Me.TreeView_From.PointToScreen(New Point(0, 0))
        oFrom_Point = Me.TreeView_From.PointToClient(New Point(ptX.X, Cursor.Position.Y))
0
 

Author Closing Comment

by:Murray Brown
ID: 37813049
Thanks very much
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

622 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