how to clear lines drawn on a panel.on some event i want to clear lines which r previosly drawn

I think the only way to do that, is to draw over the line in the same color as the background of the window. I'm pretty sure you can't delete them.

It would still be there, but not visible anymore.

Hi,

Here's a small example how to draw a line on a panel and to clean the panel:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim redPen As Pen = New Pen(Color.Red, 2)
        Dim point1 As Point = New Point(10, 10)
        Dim point2 As Point = New Point(120, 180)
        Panel1.CreateGraphics.DrawLine(redPen, point1, point2)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Panel1.Invalidate()
    End Sub

I thought he wanted specific lines to be removed, not all of them at once.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.