I have panels in scroll view pnlUsers. Defined in global.
When user clicks panel it fires pnlUsers_Click event.
I have used it dozens of times but this time sender object is not having Tag value i assigned to it while adding panels to scroll view panel.
Any reasons.
Adding panel
B4X:
pnl.Initialize("pnl")
pnl.LoadLayout("Panel_Users")
lblMemberName.Text=m.Get("MemberName")
lblMemberID.Tag=m.Get("MemberID")
pnl.Tag=m.Get("MemberID")
If n=0 Then
svUsers.Panel.AddView(pnl,0,0,100%x,9%y)
svUsers.PANEL.Height=pnl.Height
Else
svUsers.Panel.AddView(pnl,0,svUsers.Panel.Height+1%y,100%x,9%y)
svUsers.PANEL.Height=svUsers.PANEL.Height+1%y+9%y
End If
Firing event
B4X:
Sub pnlUsers_Click
Dim pnlx As Panel
pnlx=Sender
SelectedUserdID=pnlx.tag
StartActivity("frmViewUserProfile")
End Sub
Hi JordiCP,
No pnl is a local variable, pnlUsers i defined as global variable corresponding to the view i have taken in designer.
The event pnlUsers_Click is firing properly as it should.Sender is giving value "txt" which is incorrect.
Juzer
But the Tag belongs to pnl and not to pnlUsers.
Try to set pnlUsers.Tag = m.Get("MemberID")
I'm not sure, but I think, in thar case, that you need to declare pnlUsers also local and not as global, otherwise pnlUsers will link to the last instance.
Or maybe try pnlx.Parent.Tag
Or, you could also use, as suggested by JordiCP, pnl.Initialize("pnl") and pnl_Click and then you can get the different views on pnl with pnlx.GetView(Index).