|
|
Sign In Link to us |
|
Home 1. Introduction 2. Introducing VB 3. Projects 4. Containers 4.1 Forms 4.2 Frame & PictureBox 5. Controls 6. Code 7. Forms 8. Debugging Code 9. Error Handling 10. Objects 11. User Controls 12. Data Projects 13. API 14. Distribution
|
4. ContainersA control is an interactive element that can be placed onto a window, such as a button, text box or picture. Controls are usually placed straight onto a window from the toolbox (see earlier). Some Controls can hold other Controls - these are called Container controls.The Control which contains the other Controls is said to be the Parent Control, whilst the Controls which are held by the Container are said to be Child Controls.
![]() In the picture above, "Form1" is a container for "Frame1" and the "Exit" button. Note that "Frame1" is a container for the text box, "Text1" and the "OK" button. Child Controls are grouped together inside the Parent Control. E.g. If a Control is a Container, it's Child Controls will move when it moves. For example, if "Frame1" in the picture above was moved, "Text1" and the "OK" button would move with it.
4.1 FormsThe simplest way to describe a Form is as a window. When using Windows, almost all of the user-interface is done through Forms (with exceptions such as the desktop and the system tray). A Form is not itself a control.A Form is an object that can contain other controls, such as buttons and lists - it is a Container object. When developing an application, the graphical elements can be broken down into areas of concern and placed on separate Forms. These Forms can then be opened and closed as required during the execution of the application.
Exercise iv:
Private Sub Command1_Click()
Form2.Show 1
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
4.2 Frame and PictureBox ControlsFrames and PictureBox Controls are also Containers, however, they must themselves be placed onto a Container (such as a Form or User Control). We will cover Frame and PictureBox controls later in the course.Once the Frame or PictureBox is on a Form, it can have other Controls added to it.
Exercise v:
Note:
There is no need to change the Visual Basic code associated with a Control when you move it, provided that you do not change
the (Name) property of that control.
<<Page 3 : Top : Page 5.1>> | |||