tags:

views:

32

answers:

3

how can i clear the image in a picturebox to draw a new image.

A: 
PictureBox1.Image = Nothing
rahul
its working.but there have no chance to draw a image without the form load
+1  A: 

Create a new Bitmap object with the value of width and height.

PictureBox1.Image = New Bitmap(100, 100)
adatapost
where can i place this code?on paint or button click?
Button's click event.
adatapost
+2  A: 

Suppose you have two buttons on the interface to clear the image and redraw image, you can use following functions on their click handlers.

VB

Private Sub ClearImage()
        PictureBox1.Image = Nothing
    End Sub

    Private Sub SetImage(ByVal img As Image)
        PictureBox1.Image = img
    End Sub

C#

public void ClearImage()
{
 PictureBox1.Image = null;
}

public void SetImage( Image img)
{
 PictureBox1.Image = img;
}
Mahin
oops.. I provided c# sample..
Mahin
please convert it into vb