I need to fill a button array with database results.
E.g. Database table "products" with :
ProductID Product
1 Egg
2 Ham
3 Coke
In VB it is easy to loop through a datatable,
generate a new object (e.g. button) and
fill a flowlayoutpanel.
I would like to try a same thing on B4A.
I have found a sample from the TingTong Game to generate
a button array:
the array out of the number of tablerows, with adding the column "product" as buttontext
and adding the column "ProductID" as buttontag.
Can anybody help me ?
E.g. Database table "products" with :
ProductID Product
1 Egg
2 Ham
3 Coke
In VB it is easy to loop through a datatable,
generate a new object (e.g. button) and
fill a flowlayoutpanel.
I would like to try a same thing on B4A.
I have found a sample from the TingTong Game to generate
a button array:
- Dim width, offsetX, offsetY As Int
- width = 100dip
- offsetX = (100%x - width * 3 - 10dip * 2) / 2
- offsetY = (100%y - width * 3 - 10dip * 2) / 2
- For x = 0 To 2
- For y = 0 To 3
- Dim b As Button
- b.Initialize("button") 'All buttons share the same event sub
- b.TextSize = 30
- ' b.Text = "test"
- ' Activity.AddView(b,offsetX + x * (width + 10dip), offsetY + y * (width + 10dip), width, width)
- Activity.AddView(b,offsetX + x * (width + 5dip), offsetY + y * (width + 5dip), width, width)
- ProdButtons(x, y) = b 'store a reference to this view
- Next
- Next
- dim prodbuttons(3,4) as buttons
the array out of the number of tablerows, with adding the column "product" as buttontext
and adding the column "ProductID" as buttontag.
Can anybody help me ?