Clearing a Picture box

Equis

Member
Joined
Sep 1, 2006
Messages
9
Programming Experience
Beginner
Hello

I use
MyPic.ImageLocation = Opf.FileName or drag and drop to put an image in a picture box

the mypic.image = nothing does not clear it

also this will clear it but if another form ot message box is displayed over the picturebox it will come back (the part that was covered)
Dim g As Graphics = MyPic.CreateGraphics()
g.Clear(MyPic.BackColor)
g.Dispose()


Can anyone help me clear the picture box?

Thanks




 
All you should need to do is set the PictureBox Image property to nothing. I tried this now by adding a picture box and button to a form. The buttons click event I set as:

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.PictureBox1.Image = Nothing
End Sub

This resulted in a cleared picture box for me.
 
Thats not what the clear method of the graphics class is for. That method is used to completely cover the current graphics surface with a single color.
 
Back
Top