PictureBox Control

Using as a container

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!

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.” - Dennis Ritchie