Help understanding layout controls in code

DevBaby

Active Member
Licensed User
Longtime User
Below is a piece of code from the scrollview example provided on this site. I modified it a little to set a label (lblPanelCounterLabel) on the “page1” layout created in the designer.

My question is that once I add the “p” panel to the “sv” scrollview, why does the label object (lblPanelCounterLabel) no longer modify the label field on panels I just added to “sv”. The lblPanelCounter seem to only write to the new “p” created so that this panel gets the next number and then added to the scrollview.

It works such that I get a scrollview list numbering 0 through 9, I just don’t understand why the lblPanelCounterLabel does not overwrite all of the panels on the scrollview and only the new one prior to adding it to the scrollview.

Sub Process_Globals

Dim lblPanelConterLabel As Panel​

End Sub

Sub Globals
Dim sv As ScrollView​
End Sub

Sub Activity_Create(FirstTime As Boolean)

sv.Initialize(70dip * 10)​
Activity.AddView(sv, 0, 0, 100%x, 100%y)​

For i = 0 To 9​
Dim p As Panel​
p.Initialize("")​
p.Tag = i​
p.LoadLayout("page1")​
lblPanelCounterLabel = “This is panel #” & i​
sv.Panel.AddView(p, 0, i * 70dip, sv.Panel.Width, 60dip)​
Next​

End Sub
 
Last edited:

Brendon

Member
Licensed User
Longtime User
Because each new instanca of you panel loads a new instance of your label, so you put your value in a new object, that is different in each panel
 
Upvote 0
Top