The main advantage (that I can see) of using a PictureBox as a container is when you move controls during run-time. For example, imagine you have a number of labels that you want to scroll down a part of the form. If the controls are just placed directly onto the form, you would have to create some quite complicated code to ensure that the controls are only displayed on the section of the form you wish. This is made much simpler if you do this:
Add a PictureBox to your form, and move it to the area you wish the scrolling text (or images...) to be displayed. Then, add the controls you wish to the PictureBox. To add a control so that it is contained within the PictureBox, select the PictureBox first, and then draw the control (the form is usually selected). Once the text has scrolled off the viewing area, they will be hidden behind the edges of the PictureBox. If you set one of the contained controls top property to 0, it will be displayed at the top of the PictureBox, instead of at the top of the form.
Some controls that are not contained within the picturebox (such as a line) cannot be displayed over the top of the picture box. Others, such as a text box (see above), can. Obviously, all this is quite hard to explain. I recommend you have a play (while no-one else is looking), and see what I mean. If you come up with a better way of explaining this, please email me with it!
Comments