See Also Example
Applies To
Check box, combo box
Description
Specifies the form on which a control is located; not available at design time and read-only at run time.
Usage
[form.]control.Parent
Remarks
Use the Parent property to access the properties, methods, or controls of a control's parent formfor example, MyButton.Parent.MousePointer = 4.
The Parent property is useful in an application in which you pass controls as arguments. For example, you might pass a control variable to a general procedure in a module, and use the Parent property to access its parent form.
Note There is no relationship between the Parent property and the MDIChild property. There is, however, a parent-child relationship between an MDI form and any forms in your project that have the MDIChild property set to True.
Data Type
Form
Help:
ActiveControl Property
ActiveForm Property
Programmer's Guide:
Chapter 8, "Objects and Instances"
The example passes a control from a form that doesn't have the focus to a procedure in a module, and then prints the state of the control on the parent form. To try this example, create three forms: Form1, containing a command button; and Form2 and Form3, each containing a check box. You must also create a new module (choose the New Module command from the File menu). Paste the code into the Declarations sections of the respective forms or module and then press F5 to run the program.
' Enter into Form1:
Sub Form_Load ()
Form2.Show ' Display all forms.
Form3.Show
Form2.AutoRedraw = True
Form3.AutoRedraw = True
End Sub
Sub Command1_Click ()
CheckCheck Form2.Check1 ' Call procedure in other module.
CheckCheck Form3.Check1 ' And send control as argument.
End Sub
' Enter into Module1:
Sub CheckCheck (Source As Control)
If Source.Value Then
Source.Parent.Cls ' Clear parent form.
Source.Parent.Print "CheckBox is ON" ' Print on parent form.
Else
Source.Parent.Cls ' Clear parent form.
Source.Parent.Print "CheckBox is OFF" ' Print on parent form.
End If
End Sub