Results 1 to 4 of 4

Thread: Loading and choosing pictures at runtime

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Loading and choosing pictures at runtime

    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
    Last edited by sgrya1; Apr 28th, 2018 at 06:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width