Hello everyne,
Happy new year and keep healthy for a long time
This morning, I'm faced to a little problem I don't understand.
Maybe I'm not really well awaked, but here is it:
In the sub below, at line 8, I count the number of sub panels (pan(x)) in a parent panel (pnlpnl).
The process runs, but at line 15, there is an auto increment which gives me a bad value.
Normally, each time I create a sub panel, it is placed in the parent panel and the number of the sub panels must increment by a step of 1 unit.
So, I would have : 0,1, 2, 3, 4, and so on
But, in line 17, there is an autoincrement which gives me this :
0,2,4,6,8, and so on; It creates a gap between the sub panels when they takes their place in the parent panel.
So, where am I wrong ? Where does it come from ?
[/CODE]
Happy new year and keep healthy for a long time
This morning, I'm faced to a little problem I don't understand.
Maybe I'm not really well awaked, but here is it:
In the sub below, at line 8, I count the number of sub panels (pan(x)) in a parent panel (pnlpnl).
The process runs, but at line 15, there is an auto increment which gives me a bad value.
Normally, each time I create a sub panel, it is placed in the parent panel and the number of the sub panels must increment by a step of 1 unit.
So, I would have : 0,1, 2, 3, 4, and so on
But, in line 17, there is an autoincrement which gives me this :
0,2,4,6,8, and so on; It creates a gap between the sub panels when they takes their place in the parent panel.
So, where am I wrong ? Where does it come from ?
B4X:
[CODE=b4x]Sub ajoutEtiquetteSousPanel
Dim n As Int=0
'mise en place des ajouts des panels unit
'creation et numerotation du panel unité
For Each pp As View In pnlpnl.GetAllViewsRecursive
If pp Is Panel Then n=n+1
Next
Log("np1 " & n)
Dim np1 As Int=n+1'le nombre d'units / number of units
Dim npa As Int=np1-1'le numero attribué / number of the current unit
Dim pan(np1) As Panel
pan(npa).Initialize("pUnit")
pan(npa).Tag="sp" & np
pan(npa).LoadLayout("Unit")
Log("np2 " & np1)
Dim posy As Int=pnlpnl.Top+5dip+(pnlUnit.Height+5dip)*(np1-1)
pnlpnl.AddView(pan(npa),0,posy,302dip,122dip)
lblId.Text="sp-" & (npa)