VB.net erase line between two points

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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
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
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
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
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks very much
0
All Courses

From novice to tech pro — start learning today.