我是新学习者。我正在用 Visual Basic 创建一个应用程序,我需要帮助才能将数据库中的动态数据加载到我的标签页中。
我希望 TabPages 名称为“Category Names”(来自 Tbl_Category),并且在每个 Tabpages 中我希望创建按钮,这些按钮是来自“Tbl_ItemDetails.
按钮名称将来自“ItemSKU”列。按钮图像将来自“Item_Image”列。
我搜索了很多,但无法做到。请帮助我。如果你们知道任何其他方式(没有标签页),请分享。谢谢!
这是我尝试过的一些代码。1.图像代码不起作用。2. 如果我在标签页上有更多项目,它不会显示任何滚动条。所以我只能看到几个按钮而不是全部。![在此处输入图像描述][1]
私有子 AddProductsToTabbedPanel()
Dim i As Integer = 1
For Each tp As TabPage In TabControl1.TabPages
Dim filteredProduct As ObjectQuery(Of Tbl_ItemDetails) = New ObjectQuery(Of Tbl_ItemDetails)(("SELECT VALUE P FROM Tbl_ItemDetails AS P WHERE P.CatID = " + i.ToString), cse)
Dim flp As FlowLayoutPanel = New FlowLayoutPanel
flp.Dock = DockStyle.Fill
For Each tprod As Tbl_ItemDetails In filteredProduct
Dim b As Button = New Button
b.Size = New Size(100, 100)
b.Text = tprod.ItemSKU
' ''how can i get image on button. bellow code is not working
'b.BackgroundImage = tprod.Item_Image
'b.Image = tprod.Item_Image
b.Tag = tprod
AddHandler b.Click, AddressOf Me.UpdateProductList
flp.Controls.Add(b)
Next
tp.Controls.Add(flp)
i = (i + 1)
Next
End Sub