I am trying to insert a filled picturebox when my form loads.
My current code:

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Seatimage As PictureBox = New PictureBox()
        Seatimage.Name = "Seatimage"
        Seatimage.Location = New System.Drawing.Point(419, 134)
        Seatimage.AutoSize = True
        Seatimage.Size = New System.Drawing.Size(65, 23)
        Seatimage.ImageLocation = ("C:\Users\Harley\Desktop\Untitled.png")
        Seatimage.Load()
        Seatimage.TabIndex = 4
    End Sub

When i load the page, no image shows. Any help?
Also, can anyone help to explain how to perform this with multiple pictureboxes,using a loop, spaced out evenly over the form.
Thanks loads Guys.

You might want to try this:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Seatimage As New Windows.Forms.PictureBox
        Seatimage.AutoSize = True
         PictureBox1.Image = Image.FromFile(System.IO.Path.Combine("C:\Users\Harley\Desktop\Untitled.png"))
        Seatimage.TabIndex = 4
    End Sub

End Class

No luck sorry, this changes nothing, even when combined with the previous code :/

I was given this before, but it is a bit too advanced for me and i don't understand it. It doesnt work completely, as it fails at the "inherits" section.

Public Class ConcertSeat

    Private _row As Integer
    Private _column As Integer

    Public Property Row As Integer
        Get
            Return _row
        End Get
        Set(ByVal value As Integer)
            _row = value
        End Set
    End Property
    Public Property Column As Integer
        Get
            Return _column
        End Get
        Set(ByVal value As Integer)
            _column = value
        End Set
    End Property

    Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
        MyBase.OnMouseEnter(e)
        ' do rollover
    End Sub
    Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
        MyBase.OnMouseLeave(e)
        ' etc
    End Sub

    Private SeatList As New List(Of ConcertSeat)

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
                                                   Handles MyBase.Load
        Dim I As Integer
        Dim j As Integer
        Dim newSeat As ConcertSeat
        For I = 0 To 10
            For j = 0 To 10
                newSeat = New ConcertSeat
                newSeat.Row = I
                newSeat.Column = j
                ' AddHandler here does the same job as the Handles clause **!**
                AddHandler newSeat.Click, AddressOf Form1_Load
                SeatList.Add(newSeat)
                ' Add Control To Form
                ' Assume here that you have added properties 
                ' to the class that define the xDimension and 
                ' yDimension of the image so that they are laid
                ' out in a grid on your form. 
                newSeat.Top = 10 + newSeat.Width * I
                newSeat.Left = 10 + newSeat.Height * j
                Me.Controls.Add(newSeat)
            Next
        Next
    End Sub
End Class

If anybody can help translate this so it works, or help me with the original problem, i will be greatful.

O.K. here is the very very basic code to add acontrol to the controls collection, in this case a picture box and load the image into it.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Seatimage As New Windows.Forms.PictureBox
        Me.Controls.Add(Seatimage)
        Seatimage.Image = Image.FromFile(System.IO.Path.Combine("C:\Users\Harley\Desktop\Untitled.png"))

    End Sub

Your code modified would look like this.

 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Seatimage As New Windows.Forms.PictureBox()
        Me.Controls.Add(Seatimage)
        Seatimage.Name = "Seatimage"
        Seatimage.Location = New System.Drawing.Point(419, 134)
        Seatimage.AutoSize = True
        Seatimage.Size = New System.Drawing.Size(65, 23)
        Seatimage.ImageLocation = ("C:\Users\Harley\Desktop\Untitled.png")
        Seatimage.Image = Image.FromFile(System.IO.Path.Combine("C:\Users\Harley\Desktop\Untitled.png"))
        Seatimage.TabIndex = 4

    End Sub

Make sure you maximise your form as you will not see the picture if the form is too small.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.