Thankyou again. That really helped.
That really wasn't so difficult in the end.
This is what I ended up with if it helps anyone.
Code:Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim Row As Integer = 1, Column As Integer = 1 Dim ShapeList As New List(Of KeyValuePair(Of String, Bitmap)) ShapeList.Add(New KeyValuePair(Of String, Bitmap)("00", My.Resources._00)) ShapeList.Add(New KeyValuePair(Of String, Bitmap)("01", My.Resources._01)) For Each Shape In ShapeList If Column > 5 Then Column = 1 Row += 1 End If Dim btn As New Button btn.Tag = Shape.Key btn.BackgroundImage = Shape.Value btn.Height = 125 btn.Width = 250 btn.Left = 50 + btn.Width * Column btn.Top = 50 + btn.Height * Row btn.BackgroundImageLayout = ImageLayout.Stretch AddHandler btn.Click, AddressOf ButtonClicked Controls.Add(btn) Column += 1 Next End Sub Private Sub ButtonClicked(sender As Object, e As EventArgs) Dim clickedButton = DirectCast(sender, Button) MessageBox.Show($"You clicked the '{clickedButton.Tag}' button.") End Sub




Reply With Quote