Step 1, Create a Form called Form1.
Step 2, Add a TableLayoutPanel called TableLayoutPanel1.
Step 3, Make it 10 X 10 with 10% each.
Step 4, Set its anchor to T, B, L, and R. (It could be in any size in design time)
Step 5, Copy the code to Form1.vb.
Step 6, Run it, and you get it.
Step 7, If it works for you, please mark this one as 5.00. I wish to get 10 * 5.00 in 3 days.
Public Class Form1
'Use 0 based array
Private NRow As Integer = 9
Private NCol As Integer = 9
Private BtnArray((NRow + 1) * (NCol + 1) - 1) As Button
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TableLayoutPanel1.Size = Me.ClientSize
For i As Integer = 0 To BtnArray.Length - 1
BtnArray(i) = New Button()
BtnArray(i).Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
BtnArray(i).Text = CStr(i)
TableLayoutPanel1.Controls.Add(BtnArray(i), i Mod (NCol + 1), i \ (NCol + 1))
AddHandler BtnArray(i).Click, AddressOf ClickHandler
Next
End Sub
Public Sub ClickHandler(ByVal sender As Object, ByVal e As _
System.EventArgs)
MsgBox("I am button #" & CType(sender, Button).Text)
End Sub
End Class