Me.Controls() returning 2 is expected: it returns only the controls directly on the Window—in this case, the TabPanel and `GroupBox—not their descendants.
I’ve now added the missing APIs for the next release: https://feedback.objo.dev/feature/1209
TabPanel.Controls(tabIndex) returns the direct controls on a tab.
TabPanel.FindControl(name) searches recursively across every tab.
TabPanel.FindControlByTag(tag) does the same by tag.
PagePanel now has the equivalent APIs.
Because your database column names match your control names, you will not need to build a_controls():
For x As Integer = 0 To a_fields.Count - 1
Var control As Control = TabPanel1.FindControl(a_fields[x])
If control <> Nothing Then
If control IsA TextField Then
Var field As TextField = TextField(control)
field.Text = a_values[x]
ElseIf control IsA TextArea Then
Var area As TextArea = TextArea(control)
area.Text = a_values[x]
ElseIf control IsA ComboBox Then
Var combo As ComboBox = ComboBox(control)
combo.Text = a_values[x]
End If
End If
Next
FindControl() compares names case-insensitively and searches through nested containers as well.
If you specifically need to enumerate the direct controls on every tab, you will also be able to do this:
For tabIndex As Integer = 0 To TabPanel1.TabCount - 1
For Each control As Control In TabPanel1.Controls(tabIndex)
If control IsA TextField Or _
control IsA TextArea Or _
control IsA ComboBox Then
a_controls.Append(control)
End If
Next
Next
Until that release is installed, your explicitly populated a_controls array remains the appropriate workaround.