I attempted the following in a method of the WebContainer, but it’s only iterating through WebPagePanel, WebButton and WebSegmentedButton. Why is it not picking up other type of controls stated above?
For Each control As WebControl In Self.Controls
If control IsA WebTextField Then
WebTextField(control).MyMethod
ElseIf control IsA WebPopupMenu Then
WebPopupMenu(control).MyMethod
ElseIf control IsA WebRadioGroup Then
WebRadioGroup(control).MyMethod
ElseIf control IsA WebDatePicker Then
WebDatePicker(control).MyMethod
End If
Next
I have a WebPagePanel insider the WebContainer. All other controls are placed in the WebPagePanel. So that could be why? But I can’t find a Controls property of WebPagePanel.
Sure, no problem. Assuming I run the code from a control event:
Var control As WebControl
For ControlIndex As Integer = 0 To Self.LastControlIndex
control = Self.ControlAt(ControlIndex)
If control IsA WebTextField Then
WebTextField(control).CallSomeMethod
ElseIf control IsA WebPopupMenu Then
WebPopupMenu(control).CallSomeMethod
ElseIf control IsA WebRadioGroup Then
WebRadioGroup(control).CallSomeMethod
ElseIf control IsA WebDatePicker Then
WebDatePicker(control).CallSomeMethod
End If
Next
Just need to bear in mind, if a control has child controls, within which are more controls you want to access, you have to iterate through each parent. e.g. if WebPagePanel contained a WebTextField and a WebRectangle, and inside that WebRectangle there is another WebTextField, I believe you have to iterate through both the WebPagePanel and the WebRectangle to get to both WebTextField. The way I do this is to store parent controls in an Array. Then I loop through the array and run the above code in an inner loop.