Scrolling View Port Demo
Category:
Forms and ControlsType:
SnippetsDifficulty:
BeginningAuthor:
AnonymousVersion Compatibility: Visual Basic 6, Visual Basic 5
More information:
This is how to create a scrolling view port using PictureBoxes and Scroll Bars. This is handy when you have an image that is too big to be seen at one time, or too many controls that can fit on a form.
For the demo to work, do the following
- Start a new project.
- On Form1 put a VScrollBar and a PictureBox
- Inside of the PictureBox put a second PictureBox.
- Don't worry about sizing them. That will be taken care of in code.
- Put a command button inside Picture2.
- Copy the code below into Form1 declarations section. It will become the Form1_Resize() event and the Vscroll1_Cahnge() event.
- Press F5 to run the program. When you scroll the scroll bar the command button should scroll out of site.
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: