When a program draws on a PictureBox, the control's Image property contains the image the PictureBox uses to redisplay itself (for example, if it gets covered by another window and then exposed). The Picture property stores the PictureBox's permanent value. After drawing text, lines, or other stuff on the picture, the program can make it permanent by setting the Picture property equal to the Image property.
When you call a PictureBox's Cls method, it resets its image to the value stored in the Picture property. That means you can draw temporary lines on the picture and erase them by calling Cls.
To make the lines permanent, set the Picture property equal to the Image property.
Use this program's Load Picture button to load a picture. Click and drag to scribble on the picture. Click the picCats.Cls button to erase the scribbles and restore the picture.
Click the "picCats.Picture = picCats.Image" button to make the scribbles permanent. Then scribble some more and click the picCats.Cls button to remove the more recent scribbles.
Use the Clear button to clear the picture completely.
|