Hi, is it possible to add a button to a panel from code?
I use the following to add data from a database, which works well and every button is correctly named during the build but when you select any button from the various panels added they all refer to the last one entered, i.e. if I have 11 entries, Qty = 11 and I click on any of the buttons that are in the form (from Designer) I get the text and tag = 11, and if it is possible how would I create the button_click so it caters for all the entries as this would be variable
I need the button so I can click on it to edit the relevant entry in the database, using the ID held
Many thanks in anticipation
I use the following to add data from a database, which works well and every button is correctly named during the build but when you select any button from the various panels added they all refer to the last one entered, i.e. if I have 11 entries, Qty = 11 and I click on any of the buttons that are in the form (from Designer) I get the text and tag = 11, and if it is possible how would I create the button_click so it caters for all the entries as this would be variable
I need the button so I can click on it to edit the relevant entry in the database, using the ID held
Many thanks in anticipation
B4X:
If Qty=0 Then
ToastMessageShow("No data", False)
btnFirstSave.Visible = True
Else
Dim i As Int
MySql="SELECT * FROM medication"
cursor1 = SQL1.ExecQuery(MySql)
btnFirstSave.Visible = False
For i =0 To Qty-1
Dim footer As B4XView = xui.CreatePanel("")
footer.SetLayoutAnimated(0,0,0,100%x, 250dip)
footer.LoadLayout("medicines")
CustomListView1.Add(footer,"")
cursor1.Position = i
btnID.Text = cursor1.GetString("id")
btnID.Tag = cursor1.GetString("id")
lblMedication.Text = cursor1.Getstring("drug")
lblDose.Text = cursor1.GetString("dose")
lblIssued.Text = cursor1.GetString("dateissued")
lblNext.Text = cursor1.GetString("lastissue")
lblDirections.Text = cursor1.GetString("directions")
Next
btnFirstSave.Visible = False
End If
End Sub
Sub btnID_Click
Log(btnID.Tag & " - " & btnID.Text)
End Sub