Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 3 Working with Toolbox Controls 79



  1. Select the first PictureBox control named PictureBox1.

  2. Click the Image property in the Properties window, and then click the ellipsis button in
    the second column.
    The Select Resource dialog box appears.

  3. Click the Local Resource radio button, and then click the Import button.

  4. In the Open dialog box, navigate to the C:\Vb10sbs\Chap03 folder.

  5. Select Calcultr .bmp, and then click Open.

  6. Click OK in the Select Resource dialog box.


The calculator appears in the PictureBox.


  1. Set the SizeMode property on the PictureBox to StretchImage.

  2. Set the following properties for the check box and PictureBox2 objects:


Object Property Setting
CheckBox1 Checked
Text

True
“Calculator”
CheckBox2 Text “Copy machine”
PictureBox2 SizeMode StretchImage

In these steps, you’ll use the check boxes to display and hide images of a calculator
and a copy machine. The Text property of the check box object determines the
contents of the check box label in the user interface. With the Checked property, you
can set a default value for the check box. Setting Checked to True places a check mark
in the box, and setting Checked to False (the default setting) removes the check mark.
I use the SizeMode properties in the picture boxes to size the images so that they
stretch to fit in the picture box.
Your form looks something like this:
Free download pdf