13.8. PictureBoxesA PictureBox displays an image. The image can be one of several formats, such as bitmap, GIF (Graphics Interchange Format) and JPEG. (Images are discussed in Chapter 17, Graphics and Multimedia.) A PictureBox's Image property specifies the image that is displayed, and the SizeMode property indicates how the image is displayed (Normal, StretchImage, Autosize or CenterImage). Figure 13.29 describes common PictureBox properties and a common event.
Figure 13.30 uses a PictureBox named picImage to display one of three bitmap images image0, image1 or image2. These images are located in the project's bin/Debug and bin/Release directories in the subdirectory images. Whenever a user clicks the Next Image Button, the image changes to the next image in sequence. When the last image is displayed and the user clicks the Next Image Button, the first image is displayed again. Event handler btnNext_Click (lines 1017) uses Integer variable imageNum to store the number of the image we want to display. We then set the Image property of picImage to an Image (lines 1516). Figure 13.30. Using a PictureBox to display images.
|