I have list of buttons lets say
Button1 Button2 etc.
And I have table which will store restaurant table number, in my select query will display all the table like
1
2
3
4 etc.
Now I want bind all the buttons with table numbers like
1 2 3 4
5 6 7 8
Public Sub New()
InitializeComponent()
AddButtons()
End Sub
Private Sub AddButtons()
Dim xPos As Integer = 0
Dim yPos As Integer = 0
Dim n As Integer = 0
' Declare and Initialize one variable
Dim btnArray(35) As System.Windows.Forms.Button
For i As Integer = 0 To 35
btnArray(i) = New System.Windows.Forms.Button
Next i
While (n < 35)
With (btnArray(n))
.Tag = n + 1 ' Tag of button
.Width = 75 ' Width of button
.Height = 25 ' Height of button
'.UseVisualStyleBackColor = True
.Dock = DockStyle.Fill
.FlatStyle = FlatStyle.Flat
If (n = 13) Then ' Location of second line of buttons:
xPos = 0
yPos = 20
End If
.Top = yPos
TableLayoutPanel1.Controls.Add(btnArray(n)) ' Let panel hold the Buttons
xPos = xPos + .Width ' Left of next button
AddHandler .Click, AddressOf Me.ClickButton
n += 1
End With
End While
End Sub