Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

The Picture Box Control

If you applied everything you knew about the Image control to the Picture Box control, you could use the Picture Box control. The Picture Box control works almost exactly like the Image control, with these exceptions:

The Picture Box control automatically clips the image if it will not fit within the Picture Box control's borders that you set when you placed the Picture Box control.

Suppose that you placed a rather large Picture Box control on the form but then loaded a graphic file image into the picture box that was much smaller, such as an icon. The Picture Box control would not resize, so the image would appear inside the Picture Box control (see Figure 18.4).

18fig04.jpg

Figure 18.4 The Picture Box control doesn't always shrink to fit.

The AutoSize property, normally set to False, determines how the Image control responds to a loaded image's size. If AutoSize is False, the control doesn't resize to fit the image. If, however, you change AutoSize to True, the image control does resize to the image's measurements and doesn't clip. Therefore, the image will always shrink or expand as needed to fit the Image control's size when you set AutoSize to True.

Use the Align property to determine where on the form the Picture Box control appears. You can dock the control to any side of the Form window control using the Align property values described in Table 18.2.

Table 18.2. Possible Align property values.

Property Value Description
0-None The Picture Box control appears where you place it in the Form window.
1-Align Top The Picture Box control appears at the top of the Form window.
2-Align Bottom The Picture Box control appears at the bottom of the Form window.
3-Align Left The Picture Box control appears at the left of the Form window.
4-Align Right The Picture Box control appears at the right of the Form window.

Share ThisShare This

Informit Network