Solved

VB.net get X position of left of TreeView

Posted on 2012-04-03
7
299 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: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
  • 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:murbro
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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:murbro
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:murbro
ID: 37813049
Thanks very much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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