VaraPrasad

Hi,

Please help in below code to solve the problem.

Here the Code i written in my project. i want clear the graphics means lines only not the backgroud image of picturebox. In my code its clearing the lines aswell as image also. can any one please help me to solve this issue.

Here the code:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim frmGr As System.Drawing.Graphics

frmGr = PictureBox1.CreateGraphics()

Dim myPen As System.Drawing.Pen

myPen = New System.Drawing.Pen(System.Drawing.Color.Black)

frmGr.DrawLine(Pens.Green, 100, 20, 200, 20)

myPen.Dispose()

frmGr.Dispose()

End Sub

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

PictureBox1.CreateGraphics.Clear(Me.PictureBox1.BackColor)

End Sub

End Class

Thanks,

Vara