Solved

VB.net get X position of left of TreeView

Posted on 2012-04-03
7
290 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 85

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 85

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

21 Experts available now in Live!

Get 1:1 Help Now