O'Reilly logo

C# Primer: A Practical Approach by Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.11. Adding a PictureBox Control

The simplest way of displaying an image is through the PictureBox control. The steps to do this are as follows:

1.
Click on PictureBox in the Windows Forms Toolbox window and drag it onto the form.
2.
In the Properties box, in the Image entry, click on the right-hand gray box.
3.
An open-file dialog box pops up. Select an image for the dialog to open. When you click Open, the image is displayed within the picture box as, for example, in Figure 6.17.
Figure 6.17. A Simple Use of the PictureBox Control

4.
Resize the picture box to best display the image.

As a somewhat more complex example, let's add event handling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required