Adding Controls to a Form
Now that you’ve set the initial properties of your form, it’s time to create a user interface by adding objects to the form. Objects that can be placed on a form are called controls. Some controls have a visible interface with which a user can interact, whereas others are always invisible to the user. You’ll use controls of both types in this example. On the left side of the screen is a vertical tab titled Toolbox. Click the Toolbox tab to display the Toolbox window to see the most commonly used controls, expanding the Common Controls section if necessary (see Figure 1.8). The toolbox contains all the controls available in the project, such as labels and text boxes.
FIGURE 1.8 The toolbox is used to select controls to build a user interface.
Clicking off the toolbox makes it disappear. To make the toolbox stay visible, even when you click something else, click the little picture of a pushpin located in the toolbox’s title bar.
I don’t want you to add them yet (I’ll walk you through the process), but your Picture Viewer interface will consist of the following controls:
- Two Button controls: The standard buttons that you’re used to clicking in pretty much every Windows program you’ve ever run.
- A PictureBox control: A control used to display images.
- An OpenFileDialog control: A hidden control that exposes the Windows Open File dialog box functionality.