Solved

VB.net erase line between two points

Posted on 2012-04-03
3
415 Views
Last Modified: 2012-04-03
Hi. I use the following code to draw a line between two points on a TreeView. What code would I use to clear this line

    Sub oDrawLine()

        Dim Gr As Graphics = Me.TreeView_From.CreateGraphics()
        ' Create pen.
        Dim blackPen As New Pen(Color.DarkOrange, 2)

        ' Draw line to screen.
        Gr.DrawLine(blackPen, oFrom_Point, oTo_Point)

    End Sub
0
Comment
Question by:murbro
3 Comments
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 250 total points
ID: 37801434
You've used CreateGraphics(), which is a temporary drawing surface.  To erase, just Refresh() the Form/TreeView.  If you are not calling that method from the Paint() event then it will be erased for you.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
ID: 37801550
Strange variable name, blackPen, for an orange line, even it is is dark orange :-)

If the line never cross anything else, simply create a DeleteLine method with the same code, but use the TreeView BackColor instead of the DarkOrange.
0
 

Author Closing Comment

by:murbro
ID: 37801939
thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short film showing how OnPage and Connectwise integration works.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

911 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

19 Experts available now in Live!

Get 1:1 Help Now