Home > Articles > Programming > Visual Basic

  • Print
  • + Share This
This chapter is from the book

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, and click the plus sign next to Common Controls to see the most commonly used controls (see Figure 1.8). The toolbox contains all the controls available in the project, such as labels and text boxes.

Figure 1.8

Figure 1.8 The toolbox is used to select controls to build a user interface.

The toolbox closes as soon as you've added a control to a form and when the pointer is no longer over the toolbox. To make the toolbox stay visible, you would click the little picture of a pushpin located in the toolbox's title bar.

I don't want you to add them yet, 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 to a user
  • An OpenFileDialog control: A hidden control that exposes the Windows Open File dialog box functionality
  • + Share This
  • 🔖 Save To Your Account