Returns a reference to a collection of Control objects on a Form.
Form.Controls
Control
A collection of type Control. The collection can be iterated over using For Each. Furthermore, it provides the Count property.
The Control type as a generic variable type for controls. When you declare a variable As Control, you can assign it a reference to any control. You cannot create an instance of the Control class.
Form frm1 = , 0, 0, 150, 200
// Populate Form
Ocx Command cmd = "Command", 10, 10, 100, 22
Ocx Option opt(1) = "Option 1", 10, 40, 100, 14
Ocx Option opt(2) = "Option 2", 10, 60, 100, 14
Ocx CheckBox checkbox = "Checkbox", 10, 85, 100, 14
// Display Control properties in Debug screen
Debug.Show
~SetWindowPos(Debug.hWnd, 0, 250, 0, 500, 500, 0)
Dim o As Control
Trace frm1.Controls.Count
Debug.Print
For Each o In frm1.Controls
Trace o.Name
Try
Trace o.Index
Catch
EndCatch
Debug
Next
Do : Sleep : Until frm1 Is Nothing
Debug.Hide
Accessing properties and methods of a control is faster if you use a variable declared with the same type as the control (for example, As TreeView or As Command), because GFA-BASIC 32 can use early binding. GFA-BASIC 32 must use late binding to access properties and methods of a control assigned to a variable declared As Control.
{Created by Sjouke Hamstra; Last updated: 26/09/2014 by James Gaite}