Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net erase line between two points

Posted on 2012-04-03
3
Medium Priority
?
430 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:Murray Brown
3 Comments
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 1000 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 1000 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:Murray Brown
ID: 37801939
thanks very much
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

876 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