B4J Question Getting a list of panes

Pelky

Active Member
Licensed User
Longtime User
I have pane with a number of panes on it. I need to access a pane using code and then to be able to change the labels within it.

Is this possible and if so could someone point me in the right direction... I did try GetAllviewsRecursive looking for panes but when running I get an error

Any help would be appreciated
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
for panes but when running I get an error
Please post the error, easier to help you.
B4X:
For each v as node in p0.getallviewsrecursive
If v is pane then
Dim p as pane = v
For each c as node in p.getallviewsrecursive
If c is label then
log(c.text)
End if
Next
End if
Next
This code helps you if you are getting something unexpected while iterating
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You only need one loop as getAllViewsRecursive will look inside all of the child panels.

B4X:
    For Each v As Node In MainForm.RootPane.getallviewsrecursive ' of wherever you want to start
        If V Is Label Then
            Log(V.As(Label).Text)
            Log(V.As(Label).Tag)
        End If
    Next

Should do it.
 
Upvote 0

Pelky

Active Member
Licensed User
Longtime User
Please post the error, easier to help you.
B4X:
For each v as node in p0.getallviewsrecursive
If v is pane then
Dim p as pane = v
For each c as node in p.getallviewsrecursive
If c is label then
log(c.text)
End if
Next
End if
Next
This code helps you if you are getting something unexpected while iterating
that is amazing - that works great - I really want to thank you very much for your assistance....
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Cross platform solution:
B4X:
   For Each v As B4XView In MainForm.RootPane.getallviewsrecursive ' of wherever you want to start
        If V Is Label Then
            Log(V.Text)
            Log(V.Tag)
        End If
    Next
Note that buttons, edittexts, checkboxes and a few other views are actually subclasses of label and will also return True for V Is Label.
 
Upvote 0
Top