Have a look at below code. This is only an idea.
Public Class Form1
WithEvents oBtn As Button
Public Sub New()
InitializeComponent()
Dim oDt As DataTable = Nothing
Dim i As Integer = 0, btn As Button = Nothing
oDt = GetData()
For i = 0 To oDt.Rows.Count - 1
btn = New Button
With btn
.Parent = Me
.Left = 8
.Top = i * 24 + 8
.Text = oDt.Rows(i).Item("MyIntegerColumn").ToString
.Name = "Button" & i.ToString
AddHandler btn.Click, AddressOf oBtn_Click
End With
Next
End Sub
Private Function GetData() As DataTable
Dim oDT As DataTable = Nothing, oRow As DataRow = Nothing
Dim i As Integer = 0
Try
oDT = New DataTable("myIntegerData")
oDT.Columns.Add(New DataColumn("MyIntegerColumn", GetType(System.Int32)))
For i = 1 To 10
oRow = oDT.NewRow()
oRow.Item("MyIntegerColumn") = i
oDT.Rows.Add(oRow)
Next
Catch ex As Data.DataException
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
End Try
Return oDT
End Function
Private Sub oBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles oBtn.Click
MsgBox(sender.Name, MsgBoxStyle.Information, "Message")
End Sub
End Class